一、PHP开头基础
使用 var_dump 来获取真正的数据类型;
例: var_dump ($flag);
echo "
"; // 光标跳转到下一行;
1,什么是PHP:
PHP,一个嵌套的缩写名称,是英文超级文本预处理语言(PHP:Hypertext Preprocessor)的缩写.
2,ECHO语句:
echo 语句是PHP中的输出语句,代码如下:
echo "1234";
?>
3,连接符“.”
echo "hi"."inout";
?>
结果:hiinout;
4,注释:
在PHP中用//来表示注释。但是注释必须在之间。
二、变量
1,变量
A.变量可以复制,但是他只保留最后一次的值;
B.定义变量:
$var_namu = "231414";
变量名 变量值(此处为字符串型)
?>
C.命名规则:
a.以$进行标识。
b.以字母或下划线开头;
c.变量名可以由字母、数字、下划线(英文)、汉字组成。
d.变量名不许含有空格,当变量名由多个单词组成时可用下划线(英文)连接。
e.变量名区分大小写。
2.变量的数据类型。
变量的类型便是数据的类型。例如超市的包装袋。不同的商品要使用不同的包装袋。不同的变量也要规定不同的变量类型。
定义四种常用的变量类型:
A.$var_string = "123"; 定义字符串型变量。
B. $G = "1231313" ; 定义整形变量。
C. $F = "123.554" ; 定义浮点型数据。
D.$faf = array("123");定义数组;定义数组需要array(),标识;
3.在PHP中,支持8种原始类型,其中包括四种标量类型,两种复合类型和两种特殊类型;
①、布尔类型????????标量
布尔只有两个值,一个是ture另一个是false。不区分大小写,主要用于条件结构中;
②、整型??????标量
整型(integer):类似于常见的整数,十进制,八进制,十六进制。八进制前加 0;十六进制前加 0x;
③、浮点型??????标量
浮点型(浮点数、双精度数或实数),即通常所说的小数。可以用小数点或者科学计数法表示,e和E等价;
例:
$num_float = 1.234;
$mun_float2= 1.234*10e9;
?>
④、字符串??????????标量
A,字符串是由一系列字符组成,在PHP中,字符和字节一样,也就是说,一共有256种不同的可能性;字符串可以用三种方法定义,单引号,双引号,heredoc结构形式:
$str_string1 = '我要成为PHP大牛';
$str_string2 = "我一定可以在本月中旬找到PHP的工作";
?>
B,字符串中包含单引号和双引号是的处理方式;
$str_string1= '"12312"'; //单引号拥抱双引号;
$str_string2 = "'guahugaghu'"; //双引号拥抱单引号;
$str_string3 = "\"ghasgaho\""; //双引号拥抱双引号;
$str_string4 = '\'huwsehraw\''; //单引号拥抱单引号;
?>
C.字符串中包含变量时:
当双引号中包含变量时,则双引号内容与变量内容链接在一起输出,若单引号中包含变量时,则变量名以字符串形式输出;
$love = "huozhe";
$love1 = "woyao,$love";
$love2 = 'woyao,$love';
echo $love1;
echo "
";
echo $love2;
>
运行结果:woyao,huozhe
woyao,$love
D.当要输出的字符串很长时,可以用heredoc结构解决;
$data_string =
使用的字符串,想输多少都可以;
my;
?>
⑤资源??????特殊类型
资源(resource) :资源是由专门的函数来建立和使用的,例如打开文件,数据连接。图形画布。我们可以对资源进行操作(创建,使用和释放)。任何资源,在不需要的时候都应该被及时释放,如果忘记了释放资源,系统便会启动垃圾回收机制,在页面执行完毕后回收资源,以避免内存被消耗殆尽。
例: $file_handle = fopen("data/php/f.txt","r"); //采用fopen函数打开文件夹,得到返回值则证明打开的位置确实是资源类型;
⑥ 空????特殊;
null;
被赋值为NULL,尚未被赋值的变量,被释放的变量(unsettle($werwq));
例: $wqerqiou = NULL;
$FDSF = " ";
unset($FDSF);
三 、 常量;
常量可以理解为值不变的量(如同圆周率),或者常量被定义后,在脚本的其他地方不可以被改变的量。PHP中常量被分为自定义常量和系统常量;
自定义常量,根据我们开发的需要而定义的常量,他通过使用函数 define()定义;
例 ①define("PI",3.14) == define ("常量名",常量值);
②$q = "PI";
define($q,3.14); == define ("常量名",常量值);

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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.

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

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver Mac version
Visual web development tools

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