My PHP notes (1)

I have started to learn PHP in the past few days. I will keep all my notes here, so that I can review it by myself in the future, and also help some students who are learning PHP like me.

PHP introduction :

  1. PHP (full name: PHP: Hypertext Preprocessor, namely "PHP: Hypertext Preprocessor") is a universal open source scripting language.
  2. The PHP script is executed on the server.
  3. PHP is free to download and use.
    First look at the php code in html
<!DOCTYPE html> 
<html> 
<body> 
<?php echo "Hello World!"; 
?> 
</body> 
</html>

The PHP script can be placed anywhere in the document.
PHP scripts start with <?php and end with ?>

<?php
// PHP 代码
?>

The default file extension of PHP files is ".php".
Through PHP, there are two basic commands for outputting text in the browser: echo and print.
Comments in PHP

<?php
// 这是 PHP 单行注释
/*这是 PHP 多行注释*/
?>

php variables

<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>
//输出为11

String variables in PHP

<?php
$txt="Hello world!";
echo $txt;
?>

The concatenation operator (.) is used to join two string values.
php operator operator
is similar to other languages, just use examples

<?php 
$x=10; 
$y=6;
echo ($x + $y); // 输出16
echo ($x - $y); // 输出4
echo ($x * $y); // 输出60
echo ($x / $y); // 输出1.6666666666667 
echo ($x % $y); // 输出4 
?>
<?php 
$x=10; 
echo $x; // 输出10
$y=20; 
$y += 100;
echo $y; // 输出120
$z=50;
$z -= 25;
echo $z; // 输出25
$i=5;
$i *= 6;
echo $i; // 输出30
$j=10;
$j /= 5;
echo $j; // 输出2
$k=15;
$k %= 4;
echo $k; // 输出3
?>
<?php
$x=100; 
$y="100";
var_dump($x == $y);
echo "<br>";
var_dump($x === $y);
echo "<br>";
var_dump($x != $y);
echo "<br>";
var_dump($x !== $y);
echo "<br>";
$a=50;
$b=90;
var_dump($a > $b);
echo "<br>";
var_dump($a < $b);
?>

Well, this is the end of this issue of notes, and the next issue will start the function!

Guess you like

Origin blog.csdn.net/weixin_46678271/article/details/107315158