We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
时间:2016-12-02 10:30:13
有前端两三年的基础,也有后端(Java,.NET,SQL等常规技术)的基础,然后了解下PHP最基本的使用,至少能够快速编写接口,套用模板等。
.
for($arr as $item)
代码放在 <?php ?> 代码块里面,文件以 .php 结尾
<?php ?>
.php
<?php echo "hello world" ?>
PHP是类型松散型的语言,不需要类似C# ,Java 声明指定的数据类型 但是变量 必须 以 $ 开头
$num = 100 $str = "zhongxia" $pid = 3.14 $arr =
echo 和 print 功能一样, 输出内容
和其他语言一样,
$arr = array("zhongxia","age","test")
//使用指定键 => $arr = array("name"=>"zhongxia","age"=>18) //使用常规方式 $arr["name"] = "zhongxia" #arr["age"] = "18"
和其他语言一样,没有什么特殊的
+ - * / % == === != += -= ...
主要不同点是 elseif
可以用 and ,or , && , ||
and == && or == ||
if($x >1 && $x < 10){ //... }elseif($x>10 && $x <100){ //... }else{ //... } //swich switch ($x) { case 1: echo "Number 1"; break; case 2: echo "Number 2"; break; case 3: echo "Number 3"; break; default: echo "No number between 1 and 3"; }
for, while ,do..while, foreach
$i = 0; for($i; $i<10; $i++){ echo '循环次数' . $i } while($i<10){ echo 'while循环' . $i $i++; } $arrs = array("red","green","blue","yellow"); foreach ($arrs as $value) { echo "$value <br>"; }
定义常量 和 其他的C#,java 不太一样 需要使用 define 来定义
//第一个参数就是常量的名称 define("GREETING", "Welcome to W3School.com.cn!"); echo GREETING; //常量名不区分大小写, 第三个参数使用 true define("GREETING", "Welcome to W3School.com.cn!", true); echo greeting;
//函数的定义,设置参数,默认参数 function say($name,$age=18){ echo 'this is a function! $name' }
就是PHP内置的一些全局变量,不需要自己定义。 使用他们也不需要引入任何东西,直接开始用就行。
$GLOBALS $_SERVER $_REQUEST $_POST $_GET $_FILES $_ENV $_COOKIE $_SESSION
The text was updated successfully, but these errors were encountered:
No branches or pull requests
零、和其他语言的不同点
.
, 使用 点, 而不是 + 号,注意for($arr as $item)
数组在前一、PHP常规知识点
1. php代码块
代码放在
<?php ?>
代码块里面,文件以.php
结尾2. 声明变量
PHP是类型松散型的语言,不需要类似C# ,Java 声明指定的数据类型
但是变量 必须 以 $ 开头
3. echo 和 print
echo 和 print 功能一样, 输出内容
4. 数据类型
和其他语言一样,
$arr = array("zhongxia","age","test")
5. 运算符
和其他语言一样,没有什么特殊的
6. 判断语句 (if..elseif...else, switch)
主要不同点是 elseif
可以用 and ,or , && , ||
and == &&
or == ||
7. 循环
for, while ,do..while, foreach
8. 定义常量
定义常量 和 其他的C#,java 不太一样
需要使用 define 来定义
9. 函数, 和JavaScript一样
10. 超全局变量
二、学习网站
The text was updated successfully, but these errors were encountered: