坏狼的PHP学习教程之第3天第1/2页
今天更上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 }
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
