search
Homephp教程php手册坏狼的PHP学习教程之第3天第1/2页

坏狼的PHP学习教程之第3天第1/2页

Jun 13, 2016 pm 12:28 PM
phpsuperiorcodecopyStudy tutorialnumberofAdd

今天更上1层楼了...先写1个:(数字相加的) 

 

复制代码 代码如下:


 $a = "10";  //将右边"连"到左边 
 $a += "2";  //将右边"加"到左边 
 echo $a."
\n";  //这里结果是12,大概意思就是,$a等于10了,然后又把2加到左边(就是$a了),所以就是12了. 
  ?> 


我看来php写法很注重行的概念,不管$a代表什么,大概意思都是右边到左边."连到"或"加到"或"减到"等,!不只是数字之间的加连。还可以其他方式.
再写1个:(右连到左内容的) 

 

复制代码 代码如下:


    $b = "坏狼";    
   $b .= "大好人!";   
   $b .= "大好人!"; 
   echo $b."呵呵!\n"; //显示最终内容! 
  ?> 



结果为什么这样显示呢?如果你每次都认真听的话,前段会说:程序的跑法是从上到下,从右到左的原则.


再写1个:(除法的) 

  
 

复制代码 代码如下:


 $a = "65896255618562314793123219";  //在这里复杂的下计算,原来php处理这里简单! 
 $a /= "465342233234234"; //让这2个数字相乘! 
 echo $a."←这是结果!65896255618562314793123219除以465342233234234,哇一般人算术没我快!呵呵@!\n"     
 ?> 



得到结果141608156132,算的速度还真快,呵呵......

继续下1大步骤:
1.位元的运算(这个很少用)
& 代表且(and)
| 代表或(or)
^ 代表互斥(Xor)
>> 向右移位
~ 取1的辅数
2.逻辑运算(条件等)
>  代表大于
>= 大于或等于
== 等于  (一般检查例如用户的登陆等于不等于条件)
!= 不等于
&& and 而且 (and)
|| or 或者(or)
xor 互斥(Xor)
! 不(Not)
其他符号
3.其他运算
$ 变数(用到很多次了)
& 变数的指标(加在变数前)
@ 不显示错误信息(加在函数前)     
      例子

复制代码 代码如下:


    @include("dbx.txt");  //如果dbx.txt不存在会报告错误,但加@之后就不显示了! 
   echo "
\n"; 
   ?> 



-> 物件的方法或者属性
=> 阵列的元素值
?: 三远运算子


上边的记住就可以了,(但是记住也不是那么容易地,呵呵!)
下边介绍更高层的了,也是写程序比较常用关键的!

1.单行的if(判断)
if...else... 
如果...什么什么...结果怎样...负责...怎样...
如果...你胖...你是小猪...否则...你是瘦猴子.
if(conditon) { statment1}    true  真 
else {statment2}             false 假
例子:

  $a = 4.998;
  if($a > 5)    //这里不需要加分号,注意!
    {
    echo "对了!a > 5\n";
    }
    else       //这里不需要加分号,注意!
    {
    echo "错了!a     }   
?>

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.