PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

PHP 基础教程1 php语言基础 php0基础 php基础实

原创
2016-07-29 08:49:16 1038浏览

什么是 PHP 文件?

PHP 文件能够包含文本、HTML、CSS 以及 PHP 代码
PHP 代码在服务器上执行,而结果以纯文本返回浏览器
PHP 文件的后缀是 “.php”


PHP 能够做什么?

PHP 能够生成动态页面内容
PHP 能够创建、打开、读取、写入、删除以及关闭服务器上的文件
PHP 能够接收表单数据
PHP 能够发送并取回 cookies
PHP 能够添加、删除、修改数据库中的数据
PHP 能够限制用户访问网站中的某些页面
PHP 能够对数据进行加密
通过 PHP,您可以不受限于只输出 HTML。您还能够输出图像、PDF 文件、甚至 Flash 影片。您也可以输出任何文本,比如 XHTML 和 XML。


PHP 支持三种注释:

html>body>// 这是单行注释# 这也是单行注释/*
这是多行注释块
它横跨了
多行
*/?>body>html>

PHP 大小写敏感

在 PHP 中,所有用户定义的函数、类和关键词(例如 if、else、echo 等等)都对大小写不敏感。
在下面的例子中,所有这三个 echo 语句都是合法的(等价):
实例

html>body>ECHO"Hello World!
"
; echo"Hello World!
"
; EcHo"Hello World!
"
; ?>
body>html>

Hello World!
Hello World!
Hello World!


不过在 PHP 中,所有变量都对大小写敏感。
在下面的例子中,只有第一条语句会显示 colorcolor、COLORcoLOR 被视作三个不同的变量):
实例

html>body>$color="red";
echo"My car is " . $color . "
"
; echo"My house is " . $COLOR . "
"
; echo"My boat is " . $coLOR . "
"
; ?>
body>html>

My car is red
My house is
My boat is


PHP 5 echo 和 print 语句

PHP echo 和 print 语句

echo 和 print 之间的差异:
echo - 能够输出一个以上的字符串
print - 只能输出一个字符串,并始终返回 1
提示:echo 比 print 稍快,因为它不返回任何值。

PHP echo 语句
echo 是一个语言结构,有无括号均可使用:echo 或 echo()。

html>body>echo"

PHP 很有趣!

"
; echo"Hello world!
"
; echo"我计划学习 PHP!
"
; echo"这段话", "由", "多个", "字符串", "串接而成。"; $txt1="Learn PHP"; $txt2="W3School.com.cn"; $cars=array("Volvo","BMW","SAAB"); echo$txt1; echo"
"
; echo"Study PHP at $txt2"; echo"
"
; echo"My car is a {$cars[0]}"; ?>
body>html>

Hello world!
我计划学习 PHP!
这段话由多个字符串串接而成。
Learn PHP
Study PHP at W3School.com.cn
My car is a Volvo

PHP print 语句
print 也是语言结构,有无括号均可使用:print 或 print()。

html>body>print"

PHP is fun!

"
; print"Hello world!
"
; print"I'm about to learn PHP!"; $txt1="Learn PHP"; $txt2="W3School.com.cn"; $cars=array("Volvo","BMW","SAAB"); print$txt1; print"
"
; print"Study PHP at $txt2"; print"
"
; print"My car is a {$cars[0]}"?>
body>html>

PHP is fun!

Hello world!
I’m about to learn PHP!
Learn PHP
Study PHP at W3School.com.cn
My car is a Volvo

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP 基础教程1,包括了php,基础方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。