Finally, the environment has been configured. Try PHP!
Where can I write the code?
<? Php code?>
<? Code?>
<% Code %>
<Script language = "php"> code </script?>
Mark the author. Why comment?
// Author: matter
/*
* Author: matter
*/
# Author: matter
Finally officially started. OK, go directly to the classic case
<? Php echo 'Goodbye world ~ ';?>
<? Php echo "Goodbye world ~ ";?>
<? Php print "Goodbye world";?>
<? Php printf ("Goodbye World");?>
Pay attention to the color-changing part.
Single quotation marks are acceptable. Double quotation marks are also acceptable.
The support for escape characters in single quotes is incomplete!
Echo works, print works, and printf works.
Why is printf in parentheses?
The parentheses of echo () and print () can be omitted.
Is echo different from print?
Echo () has no return value. print () successfully outputs 1
It can be seen that echo () is faster than print!
Use printf for dynamic text, and echo for static text
$ Test = Sprint ("$ %. 2f", 12.3424 );
Printf ("Goodbye -- World, $ test ");
Sprintf can assign values to variables ~
It's time to let me see the variables!
Weak language-everything is scalar (scalar)
$ MyVar = "anything ";
Array
$ Arr [0] = "abc ";
It's time to see the object!
Class MyTest {
Private $;
Public function getA (){
Return $ this->;
}
Public function setA ($ ){
$ This-> a = $;
}
}
$ Useage = new MyTest ();
$ Useage-> setA ("HI ~ ");
Echo $ useage-> getA ();
Feel it for me and JAVA
No function return type
Call methods and properties with "->" instead "."
Whether or not it is declared or not, add $ to the variable
I don't know what type the variable is. What should I do?
Forced conversion
(Array) $ fig
Automatic conversion
The preceding number is used for string calculation.
The If () condition determines that the calculation result is not 0.
I want to have the right to know and control the variable type!
String Gettype (mixed var );
Returns the type of the variable var.
Boolean settype (mixed var, string type)
Type of the conversion variable
How many variables are responsible?
GLOBAL $ var; // GLOBAL variable
STATIC $ var; // STATIC variable
Currently, the keywords are not the same. Other keywords are normal.
Super global variable-predefined, environment-related
$ _ SERVER, $ _ GET, $ _ POST, $ _ COOKIE
$ _ FILES, $ _ ENV
When the variable remains the same ~
Define ("PI", 3.1415 );
Operator, operand, control statement
New: AND OR NOT XOR
Others are not found at the moment...
From matter605924657