1、布尔值:false(0,空白,null); true(-1,非0值);
2、echo ''$s''输出内容是 $s;
如果""里面包含了$s或者{$s},那么将显示的变量的值。推荐使用{$s}的方式。
使用""时候,如果在""里面还要使用"",就必须用来转义,例如: echo ""sss"";
3、字符串连接:使用标点"."进行字符串连接。
4、访问字符串中的字符:通过在字符串之后用花括号指定所要字符从零开始的偏移量来访问。
strlen($str) 函数可以获取字符串长度。
$str[0] 获取字符串$str的第一个字符。
substr(''123456'',5,1) 从第5个字符开始获取一个字符,结果是“6”.
5、strval($s)将$s的值转换成字符串,intval($s)将$s的值转换成int整型数值。
双引号里面使用双引号:" a"b "=a"b ;
6、数组: (array 括号,逗号,=>)
数组排序:sort($arr);
定义:$arr=array(1=>''11'',''foo''=>''fffooo'', ''info''=>array(2=>22,''ghost''=>''host'') );
引用:$arr[1] $arr[''foo''] $arr[''info''][2] $arr[''info''][''ghost'']
count($arr) 获取数组元素数量
遍历数组:$arr=array(1=>''111'',2=>''222'',3=>''333'');
foreach($arr as $k=>$v)
echo "{$k}_{$v}
"; //输出:1_111 2_222 3_333
7、对象
class foo
{
var $a=''s'';//类的变量!!
function init() //类的函数
{
echo "Doing foo.";
echo $this->a; //引用类的变量!!
}
}
$bar = new foo;
$bar->init();
?>
8、变量
isset($s)检查变量是否已经设置,如果还没有设置就引用$s将导致php提示: Undefined variable。
默认情况下变量之间赋值是不会互相影响的(传值赋值模式);
如果是 $a="a"; $b=&$a 这种情况下,$a和$b中任一个变量的值改动了,另外一个变量的值也随之变化(传地址赋值模式)。
PHP5的预定义变量:
$_SERVER["REMOTE_ADDR&quo

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment
