PHP basic syntax and data types study notes_PHP tutorial
An entry-level article on basic PHP syntax and data types. I hope it can provide some help to all PHP beginners.
PHP basic syntax and data types:
(1), PHP basic syntax:
1. Mixed HTML and PHP
3. How to define a variable and how to use it
Four scalar types:
boolean (Boolean type) understood as true or false type
integer (integer type)
Float (floating point type, also called "double") is understood as decimal type
String (string)
array (array)
object
1. Arithmetic operations
2. Assignment operation (such as: $a=100)
3. Comparison operations (such as: $a<$b)
4. Logical operations (such as: $a&&$b)
5. Increment and decrement operations (such as: $a++)
(4) switch conditional statement
switch conditional statement
$i=1;
switch($i){
case 0;
echo "The value of i is 0";
break;
case 1;
echo “The value of i is 1″;
break;
case 2;
echo “The value of i is 2″;
break;
Default: echo "None of the above values";
?>
break n jump out of loop statement
break n jump out of n level loop
Example:
for($i=1;$i<=5;$i++){
echo “i=".$i."
";
for($j=1;$j<=5;$j++){
echo “ j=”.$j.”
”;
for($k=1;$k<=5;$k++){
echo “ k=”.$k.”
”;
If($k==2){
break;
}
}
if($j==3){
Break 2;
}
}
echo “
”;
}
?>
//Execute once before judging
do{
echo “Execution loop”;
$a++;
}while($a>100);//Note there is a semicolon
echo “
”;
//Judge first and then execute
while($a>100){
echo “Execution loop”;
$a++;
}
?>
foreach($arr as $key=>$val){}//Traverse the array
count($arr)//length of statistical array
is_array($arr)//Judge array
explode(“key”,$str)//Split the string into an array

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This chapter deals with the information about the authentication process available in CakePHP.
