一、何为php

    PHP,即“PHP: Hypertext   Preprocessor”,是一种被广泛应用的开源通用脚本语言,尤其适用于 Web 开发并可嵌入 HTML   中去。它的语法利用了 C、Java 和 Perl,易于学习。该语言的主要目标是允许 web 开发人员快速编写动态生成的 web   页面,但 PHP 的用途远不只于此。

    简单来说,就是php是一种脚本语言,可以做很多事情。①服务器端脚本 ②命令行脚本 ③编写桌面程序

二、开始php

    (1)下载php解释器,其实win下面,最简单的还是wamp这个软件,下载下来什么都有了...

    (2)win下面貌似还需要,mscvr110.dll 这个链接库,vc2012运行库,安装即可

    (3)ide,无耻的使用了 phpStorm,等哥有钱了一定给你补回来, so...

User: newasp
License:
===== LICENSE BEGIN =====
14617-12042010
00001xrVkhnPuM!Bd!vYtgydcusnqt
mM!hZWoGg"DprWxZCBwsy8T91O7MRu
NVHtrbzv8O9mmoLvtijcHSSE7i5Jr!
===== LICENSE END ====

三、入门引导

    (1)简单的输出

<"--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
//Server API => Command Line Interface

    (2)简单的表单处理

// 一个简单的html表单
<form action="action.php" method="post">
  <p>姓名: <input type="text" name="name" /></p>
  <p>年龄: <input type="text" name="age" /></p>
  <p><input type="submit" /></p>
</form>
 
// action.php 接收表单数据, 使用超全局变量
%_POST["name"]
%_POST["age"]
<"htmlcode">
<"Hello World!";
 
// 当文件为纯PHP时,最好在末尾删除PHP结束标记
//"htmlcode">
// 在一对开始和结束之外的内容,都会被PHP解释器忽略。也就是html标签和PHP代码混合的那种,跟jsp,asp一样...
<p>This is going to be ignored by PHP and displayed by the browser.</p>
<"htmlcode">
<"foo"; // a string
$a_str2 = 'foo'; // a string
$an_int = 12;   // an integer
 
echo gettype($a_bool); // prints out: boolean
echo gettype($a_str); // prints out: string
 
// If this is an integer, increment it by four
if (is_int($an_int)) {
  $an_int += 4;
}
 
// If $bool is a string, print it out
// (does not print out anything)
if (is_string($a_bool)) {
  echo "String: $a_bool";
}
"htmlcode">
echo (int)2.9; // 输出 2
echo round(2.555, 2) // 输出 2.56

// 决不要将未知的分数强制转换为 integer,这样有时会导致不可预料的结果。
<"htmlcode">
<"htmlcode">
<"$a"; // 输出 123, 转义字符 '\'
 
$str = <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
 
"htmlcode">
<"foo" => "bar",
  "bar" => "foo",
);
 
// 自PHP 5.4 起
$array = [
  "foo" => "bar",
  "bar" => "foo",
]
// key 可以是 integer 或 string 类型
// key 值为可选项, 如果未指定,则使用之前用过最大的integer键名加上1作为新键名
"htmlcode">
<"Doing foo.";
  }
}
// 用 new 实例化一个类
$f = new foo;
$f->do_foo;

    (7)Resource 资源类型

        资源 resource 是一种特殊的变量,保存了到外部资源的一个引用。资源是通过专门的函数来建立和使用的。

    (8)NULL

        特殊的NULL 表示一个变量没有值。NULL类型唯一可能的值就是NULL。

        可被认定为NULL的变量:①被赋值为NULL ②尚未被赋值 ③被unset

    (9)Callback 回调类型

        自PHP5.4 起,可以使用 callable 类型 指定回调类型 callback。

六、变量

    php中变量用一个美元符号 $ 后面跟变量名来表示的。区分大小写。

    变量默认总是传值赋值。

<?php
 
$a = 1;
// 值传递赋值 
$b = $a
// 引用赋值
$c = &$a
 
// global 关键字
global ; $GLOBALS


华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com