hi
I just watched Detective Chinatown, and it received 5 stars. Since the appointment was made long ago, it’s hard to refuse (even though it’s with a man...), but I still have to squeeze in the time to write what needs to be written. The teacher's project will be finished tomorrow morning. Although it has little to do with me, just don't cause any trouble! !
1. PHP
1. PHP Basics (3)
1.3.2 Int
Integer type.
A few points: Hexadecimal problem (2, 8, 16);
Overflow - automatically converted to float type after overflow;
divisible;
Convert float to int - round down;
Examples are given
$shi=123;
$bin=0b100001;
$ba=0123;
$shiliu =0x1234555;
function show($a){
echo "Truth is:";
var_dump($a);
echo "
";
}
show($shiliu);
show($ba);
show($bin);
$qiguaideba=01237823; //Octal "overflow" will be truncated and only output 01237
show($qiguaideba);
function zhengchu($a,$b){
$c=$a/$b;
if(is_float($c)){
var_dump(round($c) ); //Use round to control the output result
}else{
var_dump($c);
}
}
zhengchu($shiliu , $ba);
1.3.3 float
Different PHP versions, the accuracy of floating point types seems to change; and the trick is, Due to problems with the internal mechanism of PHP, there may be:
var_dump(floor((0.1 0.7)*10));
Often returns 7 instead of the expected 8....
If you want to use high precision, use the gmp function, please learn about it yourself...
If you really want to compare, you might as well set a minimum value for comparison:
$bijiao1=0.232342342;
$bijiao2=0.232342323;
$esp=0.000001;
if(abs($bijiao1-$bijiao2)<=$esp){
echo "True"."
";
}else{
echo "F**k"."
";
}
1.3.4 String
Enclosed in single and double quotation marks~
Then I just want to say one thing: heredoc:
$str= <<< EOF
alsidjflja
akjsdhflkj
dfjlkj.
EOF;
echo $str;
It basically looks like this, but note that the EOF; in the last line must be closely related to the semicolon, and there must be a line break after the semicolon, and nothing including spaces can appear before EOF;
Then heredoc can also be used to pass parameters, initialize static values, etc.;
Of course, parameters, attributes, etc. can also be called in heredoc - just think of EOF as a big double quote.
Other string-related ones, such as those I often use. Making connectors and the like is relatively basic, but easy to use. It will be clear after watching the video.
nowdoc is also a relatively new way, not very familiar, and seems to be equivalent to single quotes.
1.4 Variables
Variables are easy to use, variables are flexible, and variables are difficult to use—this is generally the way they come to be thought of.
First, PHP does not emphasize assigning an initial value and does not require a declaration, but it is recommended to assign an initial value and develop a good habit; without assigning an initial value, the variable value is the default value of its type;
Second, you need to know that reference assignment, $b=&$a; can only operate on variable names;
Third, the assignment is updated once:
$shit="asdf";
$s=123;
echo $shit;
$shit=$s;
echo $shit;
2. GD library implements image watermarks and thumbnails
1. Introduction
Use the GD library that comes with PHP to create watermarks for images.
Suitable for simple processing of large batches of images.
Learn the basic methods and then encapsulate them into a tool class.
In addition to watching Star Wars this weekend, I came here to make up for it, and I realized I was wrong. . . . .