A historic and epoch-making moment !, Historical
Narration:
Today is the first day of blog activation!
In fact, I have been learning front-end knowledge for quite a long time (after graduation, I took the time to learn it). I learned HTML, CSS, JavaScript, jQuery, Bootstrap, angularJs, it seems that I have learned a lot. In fact, I have learned more about HTML and CSS. I have read some tutorials on JavaScript. jQuery has used some methods. Bootstrap has been learning for two weeks and has read several books, angular JS is learning.
I want to summarize what I learned, but I don't seem to know where to start. In a casual manner, we will record the next 1.1 points. It is both a memory and a summary, and more importantly, it is a bit of thinking in the future. Persistence in recording what you learn every day is also a kind of wealth.
I started to learn a little about PHP today, because my company's website was written in PHP at the background, and I got all the code, but I don't know how to configure it locally. Please help me, I think it is necessary to learn a little PHP knowledge. From the front end to the back end, at least a rough website can be developed.
Main film:
1. the PHP statement ends with a semicolon (;). The close tag of the PHP code block automatically indicates a semicolon (so you do not need to use a semicolon in the last line of the PHP code block ).
2. Functions, classes, and keywords (such as if, else, and echo) in PHP are case sensitive.Insensitive.
In PHP, all variables are case sensitive.Sensitive.
(It seems that you are sensitive and not sensitive. Just set up the same set of naming rules for variables. I am used to the lower case or hump method)
3. PHP variable rules
-
- The variable starts with the $ symbol, followed by the variable name.
- The variable must start with a letter or a hyphen.
- The variable name cannot start with a number.
- Variable names can only contain numbers and Xianghua County (A-z, 0-9, and -)
- Variable names are case sensitive ($ y and $ Y are different variables)
4. JavaScript is a weak type language. PHP is better at it and does not care about the type directly. PHP automatically converts the variable to the correct data type.
5. PHP variable scope: local (local) global (global) static (static)
(AWESOME. My PHP and functions cannot access global variables)
6. global keywords can solve this problem (developers are still very intelligent)
<? Php $ x = 5; $ y = 10; function myTest () {global $ x, $ y; $ y = $ x + $ y;} myTest (); echo $ y; // output 15?>
At the same time, PHP stores global variables in the $ GLOBALS [index] array. index indicates the variable name.
1 <? Php 2 $ x = 5; 3 $ y = 10; 4 5 function myTest () {6 $ GLOBALS ['y'] = $ GLOBALS ['X'] + $ GLOBALS ['y']; 7} 8 9 myTest (); 10 echo $ y; // output 1511?>
7. Keyword static
After the function is executed, the variable will be deleted, and the variable after the static declaration will save the result after the last execution.
8. PHP echo and print statements
-
- Echo can output more than one string
- Print can only output one string, and always returns 1 ,. (With returned values)
9. There is no difference between echo and print output strings and variables, that is, the output array is a little different.
<?php$txt1="Learn PHP";$txt2="W3School.com.cn";$cars=array("Volvo","BMW","SAAB");echo $txt1;echo "<br>";echo "Study PHP at $txt2";echo "My car is a {$cars[0]}";?>
10. PHP object definition must be declared
11. NULL indicates that the variable has no value. NULL is the unique value of the NULL data type. NULL indicates whether the variable is NULL.
12. string Function
Complete string function manual
13. PHP Constants
A constant starts with a character or underscore. Once defined, the definition cannot be changed or undefined. constants run through the entire script and are automatically global.
Set PHP constants ---- use the define () function
14. PHP string Operators
String Operators
| Operator |
Name |
Example |
Result |
| . |
Concatenation |
$ Txt1 = "Hello" $ txt2 = $ txt1. "world! " |
Now $ txt2 contains "Hello world! " |
| . = |
Serial assignment |
$ Txt1 = "Hello" $ txt1. = "world! " |
Now $ txt1 contains "Hello world! " |
15. A new comparison operator in PHP <> not equal to (PHP is going to last day "! = "Difference
We will be here for the time being and continue at night. We strongly recommend that beginners study at W3school.