PHP Basics
四种标签 Standard Tags ,Short Tags,Script Tags,ASP Tags
Standard Tags <?php ... code ?>
Short Tags <? ... code ?>
<?= $variable ?> Script Tags <script language=“php”> ... code </script>
ASP Tags <% ... code %>
换行符问题: Newlines are, normally, ignored by browsers, as they are non-semantic characters in HTML. However, they are also used as separators between the header portion of a web server’s HTTP response and the actual data; therefore, outputting a newline character before all of the headers have been written to the output can cause some rather unpleasant (and unintended) consequences.
An easy way to prevent spurious output from an include file is to omit the closing tag
at the end, which the parser considers this perfectly legal.
Language constructs 语言结构 语言结构:就是PHP语言的关键词,语言语法的一部分; 它不可以被用户定义或者添加到语言扩展或者库中;它可以有也可以没有变量和返回值。 函数: 由代码块组成的,可以复用。 更多http://blog.sina.com.cn/s/blog_475429950100hk75.html die() 是exit()的别名,属于语言结构
echo 和print
It’s important to understand that echo is not a function and, as such, it does not have
a return value. If you need to output data through a function, you can use print()
instead:
echo 10;
print (10);
Data Types 数据类型 they are generally divided in two categories:scalar and composite. 标量和符合类型 更多http://sjolzy.cn/PHP-data-type-of-scalar-data-types-into-complex-data-types-special-data-types.html
4种标量类型
boolean :A value that can only either be true or false
int :A signed numeric integer value
float :A signed floating-point value
string :A collection of binary data