发现 帖子在我们的“发现”页面上探索迷人的内容和多样化的观点。发现新想法并参与有意义的对话
PHP for Loop:
The for loop - Loops through a block of code a specified number of times.
The PHP for Loop
The for loop is used when you know in advance how many times the script should run.
Parameters:
init counter: Initialize the loop counter value
test counter: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
increment counter: Increases the loop counter value
Examples
The example in image; displays the numbers from 0 to 10:
Example Explained
$x = 0; - Initialize the loop counter ($x), and set the start value to 0
$x <= 10; - Continue the loop as long as $x is less than or equal to 10
$x++ - Increase the loop counter value by 1 for each iteration
#scappy #content #php
The PHP switch Statement
Use the switch statement to select one of many blocks of code to be executed
This is how it works: First we have a single expression n (most often a variable), that is evaluated once. The value of the expression is then compared with the values for each case in the structure. If there is a match, the block of code associated with that case is executed. Use break to prevent the code from running into the next case automatically. The default statement is used if no match is found.
#scappy #php
Create a PHP Constant :-
Parameters:
name: Specifies the name of the constant
value: Specifies the value of the constant
case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false
Example
Create a constant with a case-sensitive name:
#scappy #php #code #content
PHP Variables
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).
Rules for PHP variables:
A variable starts with the $ sign, followed by the name of the variable
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive ($age and $AGE are two different variables)
#scappy #php #content
Azïz Hamza
删除评论
您确定要删除此评论吗?