当前位置:网站首页>Basic record of getting started with PHP
Basic record of getting started with PHP
2022-06-25 08:11:00 【On procedural retreat】
Basics :
1. Format
<?php echo "hello!"; ?>
2.ceho : Output
3. Connector :.
4. At the end of the paper ;
5. With notes ://
To configure :
1.apche -> httpd-vhosts.conf ( Maybe there's a version problem )
2.www Catalog modification [menu.left]
.ini
.tpl
The problem of directory garbled : use notepad++ Open to change the encoding to :ANSI
3. Multisite configuration
4. Port settings :apche-httpd.conf ,2 A place to :
1.listen : 80
2.serverName localhost : 80
Variable
1. $
$var = " Hello ";
echo $var;
2. function var_dump, Display the data type of the variable
$name = " Zhang San ";echo $name; //string(6)
$name = "123"; echo $name;//string(3)
$n = 10;echo $n;//int(10)
3. Variable names must start with a letter or underscore
Variable names can only be made of letters 、 Numbers 、 as well as “_” form , It can also contain Chinese characters
Variable names cannot contain spaces . When the variable name consists of multiple words , It is recommended to use “_” separation ( such as $my_apple), Commonly known as underline method , Or start with a capital letter, for example $myApple, Commonly known as camel nomenclature ( Also known as hump nomenclature ).
One thing in particular to note , stay PHP Variable names in are case sensitive , Such as “$my_book” And “$my_Book” Represents two different variables .
4.memory_get_usage Get current PHP Memory consumed .
5. Boolean type (boolean): There are only two values , One is TRUE, the other one FALSE, It can be understood as yes or no . It's case insensitive
When we use ”echo” When an instruction outputs a boolean type , If it is “true” The output is “1”,“false” Then nothing is output
6. String type can be defined in three ways : Single quotation marks 、 Double quotation marks and Heredoc Structure form .
7. When double quotes contain variables , Variables will be concatenated with the contents in double quotation marks ;
When single quotation marks contain variables , Variables are output as strings .
8.Heredoc Structural form method to solve this problem , First, use the delimiter to represent the string (<<<), And then “<<<“ Then provide an identifier GOD, Then there's the string , Finally, end the string with the supplied identifier
$string1 = <<<wacao
I have a little donkey , I never ride .
One day I had a whim , Ride to the market .
I have a small whip in my hand , I am proud of myself .d
I don't know why , I fell all over with mud .
wacao;
9.NULL(NULL):NULL Is an empty type , Case insensitive ,NULL Type has only one value , Indicates that a variable has no value , When assigned to NULL, Or not yet assigned , Or be unset(), In these three cases, the variable is considered to be NULL.
unset($var3);// Release $var3
var_dump($var3); NULL
Constant
1. Defined constant , It uses PHP The function in define() Definition
define("PI",3.14);// Define constants
echo PI;//3.14
2. The system constant is PHP Already defined constants , We can use it directly , Common system constants are :
(1)__FILE__ :php Program file name . It can help us get the physical location of the current file on the server .
(2)__LINE__ :PHP Number of lines of program file . It can tell us , What line is the current code in .
(3)PHP_VERSION: The version number of the current parser . It can tell us the current PHP The version number of the parser , We can know our... In advance PHP Whether the code can be PHP Parser parsing .
(4)PHP_OS: Execute the current PHP Version of the operating system name . It can tell us the name of the operating system used by the server , We can optimize our code according to the operating system
3. Use constant() function . It has the same effect as using constant name output directly
$p="";
$area = constant($p)*$r*$r;
4.defined() Function can help us determine whether a constant has been defined
5. Operator
And Logic and
Or Logic or
Xor Logical XOR
Not Logic is not
边栏推荐
猜你喜欢
Three Siemens fire-fighting hosts fc18 are equipped with can optical transceiver for optical fiber redundant ring network networking test
socket问题记录
电子学:第008课——实验 6:非常简单的开关
Deep learning series 45: overview of image restoration
allgero报错:Program has encountered a problem and must exit. The design will be saved as a .SAV file
STM32CubeMX 学习(5)输入捕获实验
Sword finger offer (simple level)
c#搭建ftp服务器并实现文件上传和下载
剑指offer刷题(简单等级)
DNS协议及其DNS完整的查询过程
随机推荐
RMQ interval maximum subscript query, interval maximum
电子学:第013课——实验 14:可穿戴的脉冲发光体
C # set up FTP server and realize file uploading and downloading
TCP acceleration notes
CVPR 2022 Oral 2D图像秒变逼真3D物体
唐老师讲运算放大器(第七讲)——运放的应用
时钟刻度盘的绘制
深度学习系列48:DeepFaker
將數據導入到MATLAB
Static web server
c#搭建ftp服务器并实现文件上传和下载
Electronics: Lesson 008 - Experiment 6: very simple switches
Luogu p5994 [pa2014]kuglarz (XOR thinking +mst)
To understand the difference between Gram-positive and Gram-negative bacteria and the difference in pathogenicity
洛谷P6822 [PA2012]Tax(最短路+边变点)
[red flag Cup] Supplementary questions
协议和服务的区别?
Stm32cubemx learning (5) input capture experiment
Ffmpeg+sdl2 for audio playback
Set the textalign property of the label control in C to control the method of text centering