写在前面的话
PHP是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP能够包含文本、HTML、CSS以及PHP代码,在服务器上执行,结果以纯文本返回浏览器
代码标识
PHP;">
PHP语句以分号(;)结尾,PHP代码块的关闭标签也会自动表明分号
PHP;">
注释
PHP;">
输出
print只能输出一个字符串,并始终返回1
echo能够输出一个以上的字符串,echo比print稍快,因为它不返回任何值
脚本之间友情提醒大家需要注意点:echo和print都是语言结构,有无括号都可以使用echo或echo(),以及print或print(),且echo或print关键字与字符串之间至少要有一个空格
PHP;">
PHP
echo "
"; echo "I'm about to learn PHP!
"; echo "This"," string"," was"," made"," with multiple parameters."; ?> PHP print "
"; print "I'm about to learn PHP!
"; //该行出错,因为print只能输出1个字符串 print "This"," with multiple parameters."; ?>
PHP is fun!
"; echo "Hello world!"; echo "I'm about to learn PHP!
"; echo "This"," string"," was"," made"," with multiple parameters."; ?> PHP print "
PHP is fun!
"; print "Hello world!"; print "I'm about to learn PHP!
"; //该行出错,因为print只能输出1个字符串 print "This"," with multiple parameters."; ?>
计算表达式
不同于HTML和CSS,在PHP中可以写计算表达式
PHP;">
大小写
在PHP中,所有用户定义的函数、类和关键词都对大小写不敏感,但所有变量都对大小写敏感
PHP;">
PHP
//Hello World!
ECHO "Hello World!
"; //Hello World! echo "Hello World!
"; //Hello World! EcHo "Hello World!
"; ?>
"; //Hello World! echo "Hello World!
"; //Hello World! EcHo "Hello World!
"; ?>
编程之家友情提醒大家需要注意点: .号代表字符串连接,在其他的编程语言中,一般用+号
PHP;">
PHP
$color="red";
//My car is red
echo "My car is " . $color . "
"; //My house is echo "My house is " . $COLOR . "
"; //My boat is echo "My boat is " . $coLOR . "
"; ?>
"; //My house is echo "My house is " . $COLOR . "
"; //My boat is echo "My boat is " . $coLOR . "
"; ?>
以上内容是小编给大家分享的前端必学之PHP语法基础,希望对大家有所帮助,同时感谢大家一直以来对编程之家网站的支持,同时祝大家元旦快乐。!