曾经简单的学习过php,看的是《php和mysql web开发》,还有万能的搜索引擎的帮助。这次准备系统的学习一下,参考资料是php manual。
php能做什么
php主要用于服务端的脚本程序,但php的功能远不局限于此。php主要用于以下三个领域:
* 服务端脚本
* 命令行脚本
* 编写桌面应用程序(php-gtk)
实用的脚本
$_server是一个特殊的php保留变量,它包含了web服务器提供的所有信息,被称为超全局变量。可以通过$_server['http_user_agent']检查浏览页面的访问者在用什么浏览器。
对于ie浏览器,$_server['http_user_agent']的值可能是:
mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; rv:11.0) like geckomozilla/5.0 (compatible; msie 10.0; windows nt 6.2; trident/6.0)mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; trident/5.0)mozilla/4.0 (compatible; msie 8.0; windows nt 6.1; trident/4.0)mozilla/4.0 (compatible; msie 7.0; windows nt 6.0)mozilla/4.0 (compatible; msie 6.0; windows nt 5.1)
可以通过调用strpos()函数,判断用户代理是否为ie浏览器。
name: inputtype=textname=name />p>p>age: inputtype=textname=age />p>p>inputtype=submit />p>form>
通过下面这段代码可以打印来自表单的数据。
hello, . you are year(s) old.
这段代码中还涉及到了htmlspecialchars()和(int)的使用。htmlspecialchars()使得html之中的特殊字符被正确的编码,从而不会被使用者在页面注入html标签或者javascript代码。
工具
工欲善其事,必先利其器。
有个好的工具,能够事半功倍。为了提高效率,我喜欢使用vim,并且在命令行中运行代码。
对于工具,这个帖子讲的不错的,window下的cmd替代工具? - windows - segmentfault。
php环境推荐使用wampserver和xampp。
(全文完)
以上就介绍了入门指引 - php手册笔记,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。