php基础部分常见的函数和关键字

WBOY
Freigeben: 2016-07-25 08:46:14
Original
946 Leute haben es durchsucht
  1. bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )
  2. explain:This requires that you place calls to this function prior to any output, including and tags as well as any whitespace.
  3. example:setcookie("TestCookie", $value, time()+3600);
  4. bool define ( string $name , mixed $value [, bool $case_insensitive = false ] ) //定义一个常量
  5. const CONSTANT = 'Hello World'; //实用关键字const定义一个常量 ,效果一样
  6. example:define("CONSTANT", "Hello world.");
  7. bool defined ( string $name ) //检查一个常量是否存在
  8. bool isset ( mixed $var [, mixed $... ] ) //检查一个变量是否存在
  9. void unset ( mixed $var [, mixed $... ] ) //释放一个变量
  10. bool function_exists ( string $function_name ) //检查一个函数是否存在
  11. string get_class ([ object $obj ] ) //获取一个对象的所属类名
  12. array get_object_vars ( object $obj ) //返回由对象属性组成的关联数组
  13. bool file_exists ( string $filename ) // 检查文件或目录是否存在
  14. 比较运算符
  15. $a == $b等于,如果类型转换后 $a 等于 $b。
  16. $a === $b全等,如果 $a 等于 $b,并且它们的类型也相同。
  17. $a != $b不等,如果类型转换后 $a 不等于 $b。
  18. $a $b不等,如果类型转换后 $a 不等于 $b。
  19. $a !== $b不全等,如果 $a 不等于 $b,或者它们的类型不同。
  20. $a $a > $b大于,如果 $a 严格大于 $b。
  21. $a $a >= $b大于等于,如果 $a 大于或者等于 $b。
  22. PHP 支持一个错误控制运算符:@。当将其放置在一个 PHP 表达式之前,该表达式可能产生的任何错误信息都被忽略掉。
  23. 执行运算符 , 反引号运算符在激活了安全模式或者关闭了 shell_exec() 时是无效的。
  24. $output = `ls -al`;
  25. echo "
    $output
    Nach dem Login kopieren
    ";
  26. ?>
  27. 字符串运算符 有两个字符串(string)运算符。第一个是连接运算符("."),它返回其左右参数连接后的字符串。第二个是连接赋值运算符(".="),它将右边参数附加到左边的参数之后。
  28. 数组运算符
  29. $a + $b联合 $a 和 $b 的联合。
  30. $a == $b相等 如果 $a 和 $b 具有相同的键/值对则为 TRUE。
  31. $a === $b全等 如果 $a 和 $b 具有相同的键/值对并且顺序和类型都相同则为 TRUE。
  32. $a != $b不等 如果 $a 不等于 $b 则为 TRUE。
  33. $a $b不等 如果 $a 不等于 $b 则为 TRUE。
  34. $a !== $b不全等 如果 $a 不全等于 $b 则为 TRUE。
  35. 类型运算符 instanceof 用于确定一个 PHP 变量是否属于某一类 class 的实例:
  36. class MyClass{}
  37. class NotMyClass{}
  38. $a = new MyClass;
  39. var_dump($a instanceof MyClass);
  40. var_dump($a instanceof NotMyClass);
  41. ?>
  42. 以上例程会输出:
  43. bool(true)
  44. bool(false)
  45. bool is_a ( object $object , string $class_name [, bool $allow_string = FALSE ] ) //如果对象属于该类或该类是此对象的父类则返回 TRUE
  46. foreach循环数组或者对象
  47. foreach (array_expression as $value)
  48. statement
  49. foreach (array_expression as $key => $value)
  50. statement
  51. require 和 include几乎完全一样,除了处理失败的方式不同之外。 require在出错时产生 E_COMPILE_ERROR级别的错误。换句话说将导致脚本中止而 include只产生警告(E_WARNING),脚本会继续运行。
  52. include 'vars.php';
  53. require_once 语句和 require语句完全相同,唯一区别是 PHP 会检查该文件是否已经被包含过,如果是则不会再次包含。
  54. goto: (相对于C语言就是一个阉割品)
  55. goto操作符可以用来跳转到程序中的另一位置。该目标位置可以用目标名称加上冒号来标记,而跳转指令是 goto 之后接上目标位置的标记。
  56. PHP 中的 goto有一定限制,目标位置只能位于同一个文件和作用域,也就是说无法跳出一个函数或类方法,也无法跳入到另一个函数。也无法跳入到任何循环或者 switch 结构中。
  57. 可以跳出循环或者 switch,通常的用法是用 goto代替多层的 break。
  58. goto a;
  59. echo 'Foo';
  60. a:
  61. echo 'Bar';
  62. ?>
  63. 以上例程会输出:
  64. Bar
复制代码

php


Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!