duan4369 2011-02-07 02:19
浏览 36
已采纳

从PHP开始?

What are some good resources for learning the fundamentals of the PHP language and an overview of frameworks available? I've been working my entire career in Javascript, C# and, in older days, VBScript. But now I find myself needing to use PHP for a project due to certain requirements. I don't want to pick PHP For Dummies but I want better information rather than learning as I build for stupid mistakes.

My main points of inquiry are: Zend Framework - Why? Is it akin to JQuery for Javascript just making regular tasks simple? Variable declaration - I've read that PHP is a loose language but what are the pitfalls? How to take advantage of this fact? General good practice structure guidelines. In C# I can create multiple classes and reference those in my Code Behind using statements. Should I apply the same principle to PHP and just include the PHP files on the pages as needed or is there a better method?

I'm looking for answers to my questions but also reliable resources for good, detailed information. I'd rather be able to fish for my dinner if you know what I mean.

  • 写回答

4条回答 默认 最新

  • du8791069 2011-02-07 02:24
    关注

    The only resource you actually need to consume (and should) is the PHP manual. It's very complete, even though it's low on practical recommendations. And download it!

    Here are some book recommendations:
    https://stackoverflow.com/questions/90924/what-is-the-best-php-programming-book
    And tutorials exist en masse.

    My main points of inquiry are: Zend Framework - Why? Is it akin to JQuery for Javascript just making regular tasks simple?

    It's a collection of utility functions. It's also a Passive/Web-MVC framework, but foremost a utility and glue code library. Some people see it as extension of the PEAR repository (also many useful classes).

    Variable declaration - I've read that PHP is a loose language but what are the pitfalls?

    PHP handles undefined variables and NULL values quite well. Many developers use heaps of isset() to check for value presence. For form processing that's usually uneeded because that's what PHP was designed for. Critical business logic might benefit from isset and type checking (is_int or is_string, is_array, etc.)

    How to take advantage of this fact? General good practice structure guidelines.

    Practice.

    I often rely on letting PHP do the optimal thing. Oftentimes you should resort to typecasting however. For objects you can meanwhile use typehinting in methods and functions. Another uncommon but advisable idiom is assert(is_array($param1));

    In C# I can create multiple classes and reference those in my Code Behind using statements. Should I apply the same principle to PHP and just include the PHP files on the pages as needed or is there a better method?

    There are multiple options. The include as needed approach is very workable for small and midsize applications. Many people rely on autoloaders for class structures, which simplifies the usage tremendously. Personally I use a central configuration file and dependency manager; loading all at once to save initialization time (but waste memory).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘