Home > Backend Development > PHP Tutorial > Android programmers learn PHP development (8) - constant predefined constant operation symbols - PhpStorm

Android programmers learn PHP development (8) - constant predefined constant operation symbols - PhpStorm

黄舟
Release: 2023-03-06 09:52:02
Original
1113 people have browsed it

Constants, predefined constants (just understand them), operation symbols (when you read this blog, you don’t need to know how the following operators operate, just understand the operators), the variable value is a string When a, ++ and -- focus on ~

examples of arithmetic operation symbols.

<?php
    /**
     * 常量
     */
    // $表示变量,可以重新赋值
    $root = "localhost";
    // define表示常量,不可以重新赋值,也不能unset()来清除常量
    define("ROOT",10,true);

    /**
     * defined() 函数检查某常量是否存在。
     * 注意,声明常量是define(),判断常量是defined()
     * 千万别写错了
     */
    if (defined("ROOT")){
        echo ROOT+10;
        echo "<br>";
    }else{
        echo "defined false";
        echo "<br>";
    }

    /**
     * 预定义常量(了解即可)
     */
    echo &#39;PHP常用的预定义常量:&#39;.&#39;<br>&#39;;
    echo &#39;当前php的版本为(PHP_VERSION):&#39;.PHP_VERSION.&#39;<br>&#39;; // 当前php的版本为(PHP_VERSION):5.6.29
    echo &#39;当前所使用的操作系统类型(PHP_OS):&#39;.PHP_OS.&#39;<br>&#39;; // 当前所使用的操作系统类型(PHP_OS):WINNT
    echo &#39;web服务器与PHP之间的接口为(PHP_SAPI):&#39;.PHP_SAPI.&#39;<br>&#39;; // web服务器与PHP之间的接口为(PHP_SAPI):cgi-fcgi
    echo &#39;最大的整型数(PHP_INT_MAX):&#39;.PHP_INT_MAX.&#39;<br>&#39;; // 最大的整型数(PHP_INT_MAX):2147483647
    echo &#39;php默认的包含路径(DEFAULT_INCLUDE_PATH):&#39;.DEFAULT_INCLUDE_PATH.&#39;<br>&#39;; // php默认的包含路径(DEFAULT_INCLUDE_PATH):.;C:\php\pear
    echo &#39;pear的安装路径(PEAR_INSTALL_DIR):&#39;.PEAR_INSTALL_DIR.&#39;<br>&#39;; // pear的安装路径(PEAR_INSTALL_DIR):C:\php\pear
    echo &#39;pear的扩展路径(PEAR_EXTENSION_DIR):&#39;.PEAR_EXTENSION_DIR.&#39;<br>&#39;; // pear的扩展路径(PEAR_EXTENSION_DIR):C:\php\ext
    echo &#39;php的执行路径(PHP_BINDIR):&#39;.PHP_BINDIR.&#39;<br>&#39;; // php的执行路径(PHP_BINDIR):C:\php
    echo &#39;php扩展模块的路径为(PHP_LIBDIR):&#39;.PHP_LIBDIR.&#39;<br>&#39;; // php扩展模块的路径为(PHP_LIBDIR):C:\php
    echo &#39;指向最近的错误处(E_ERROR):&#39;.E_ERROR.&#39;<br>&#39;; // 指向最近的错误处(E_ERROR):1
    echo &#39;指向最近的警告处(E_WARNING):&#39;.E_WARNING.&#39;<br>&#39;; // 指向最近的警告处(E_WARNING):2
    echo &#39;指向最近的注意处(E_NOTICE):&#39;.E_NOTICE.&#39;<br>&#39;; // 指向最近的注意处(E_NOTICE):8
    echo &#39;自然对数e值(M_E):&#39;.M_E.&#39;<br>&#39;; // 自然对数e值(M_E):2.718281828459
    echo &#39;数学上的圆周率的值(M_PI):&#39;.M_PI.&#39;<br>&#39;; // 数学上的圆周率的值(M_PI):3.1415926535898
    echo &#39;逻辑真值(TRUE):&#39;.TRUE.&#39;<br>&#39;; // 逻辑真值(TRUE):1
    echo &#39;逻辑假值(FALSE):&#39;.FALSE.&#39;<br>&#39;; // 逻辑假值(FALSE):
    echo &#39;当前文件行数(__LINE__):&#39;.__LINE__.&#39;<br>&#39;; // 当前文件行数(__LINE__):43
    echo &#39;当前文件路径名(__FILE__):&#39;.__FILE__.&#39;<br>&#39;; // 当前文件路径名(__FILE__):C:\Users\iwanghang\PhpstormProjects\untitled1\ceshi.php
    echo &#39;当前被调用的函数名(__FUNCTION__):&#39;.__FUNCTION__.&#39;<br>&#39;; // 当前被调用的函数名(__FUNCTION__):
    echo &#39;类名(__CLASS__):&#39;.__CLASS__.&#39;<br>&#39;; // 类名(__CLASS__):
    echo &#39;类的方法名(__METHOD__):&#39;.__METHOD__.&#39;<br>&#39;; // 类的方法名(__METHOD__):

    /**
     * 运算符号(看到这篇博客时,下面这些运算符是如何运算的不用知道,只是了解一下运算符)
     * 比如1+1,两个1都是运算云,+是运算符
     * 一元运算符:+1,-1,++,--,!
     * 二元运算符:+,-,*,/,%,>,<,=,==,===
     * 三元运算符:例如1?2:3
     * 算术运算符号:+,-,*,/,%,++,--
     * 赋值运算符号:=,+=,-=,*=,/=,%=
     * 比较运算符号:>,<,==,>=,<=,===,!=,!==
     * 位运算符号:&,|,^,~,>>,<<
     * 其他运算符号:?,:,@,=>,->
     */

    /**
     * 算术运算符号:+,-,*,/,%,++,--
     */
    echo "算术运算符号:<br>";
    $a = 13;
    $b = 2;
    echo $a + $b . "<br>"; // 15
    echo $a - $b . "<br>"; // 11
    echo $a * $b . "<br>"; // 26
    echo $a / $b . "<br>"; // 6.5
    echo $a % $b . "<br>"; // 1
    echo $a++ . "<br>"; // 13 运算结束a为13,下一次使用时a值为14
    echo $a-- . "<br>"; // 14 运算结束a值为14,下一次使用时a值为13
    echo ++$a . "<br>"; // 14 运算结束a值为14
    echo --$a . "<br>"; // 13 运算结束a值为13

    $x = "a";
    $x++;
    echo $x . "<br>"; // b
    $x++;
    echo $x . "<br>"; // c
    $x--;
    echo $x . "<br>"; // c
    $x--;
    echo $x . "<br>"; // c
    ++$x;
    echo $x . "<br>"; // d
    --$x;
    echo $x . "<br>"; // d
Copy after login

The above is the content of Android programmers learning PHP development (8)-Constant predefined constant operation symbols-PhpStorm. For more related content, please pay attention to the PHP Chinese website (www.php. cn)!



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template