The traffic of port 80 was forwarded to 192.168.0.1

2023-03-15  

Source: PHP Blog

Look at the basic knowledge of PHP, and summarize it here:

1. There are three ways to embed the PHP script in HTML:

<scriptlanguage=”php”>
// Embedding method one
echo(“test”);
</script>

<?
// Embedding method 2
echo”<br>test2″;
?>

<?php
// embedded method three
echo”<br>test3″;
?>

also has an embedded method. Even if the same label <%%> is the same as ASP, it is not recommended to use PHP.ini related configuration.

2, PHP annotation division single line and multi -line annotation, and multiple lines, andjavaThe annotation method is the same.

<?
// Here is a one -line annotation
echo”test”;
/*
Here is a multi -line comment! You can write a lot of comments content
*/
?>

Be careful not to have nested notes, such as/*aaaa/*asdfa*/asdfasdfas*/, such annotations will have problems.

3. There are 5 main data types of PHP,integer,double,string,array,object。


4. Call the function external variables in the function. You need to declare it with Global first, otherwise it will not be accessed. This is PHP and otherProgramA difference. Case code:

<?
$a=1;
functiontest(){

echo$a;
}
test (); // The result will not be output “1” here.

functiontest2(){

global$a;
echo$a;
}
test2 (); // This can output “1”.
?>



Note: PHP can declare static variables inside the function. Uses in C language.

5, variables of variables, variables of variables

<?
// Variable variables
$a=”hello”;
$$a=”world”;
echo “$ a $ hello”; // will output “HelloWorld”
echo “$ a $ {$ a}”; // The same will be output “HelloWorld”
?>

<?
// Function of variables

functionfunc_1(){

print(“test”);
}

functionfun($callback){

$callback();
}

fun (“func_1”); // This will output “test”
?>

6. PHP supports the array and associated array at the same time. You can use list () and array () to create arrays. like:

<?
$a[0]=”abc”;
$a[1]=”def”;

$b[“foo”]=13;

$a[]=”hello”;//$a[2]=”hello”
$a[]=”world”;//$a[3]=”world”

$name[]=”jill”;//$name[0]=”jill”
$name[]=”jack”;//$name[1]=”jack”
?>

7, associated parameter transmission (& use), two methods. example:

<?
// Method 1:
functionfoo(&$bar){

$bar.=”andsomethingextra”;
}
$str=”ThisisaString,”;
foo($str);
echo$str;//output:ThisisaString,andsomethingextra

echo”<br>”;
// Method two:
functionfoo1($bar){

$bar.=”andsomethingextra”;
}
$str=”ThisisaString,”;

foo1($str);
echo$str;//output:ThisisaString,

echo”<br>”;

foo1(&$str);
echo$str;//output:ThisisaString,andsomethingextra
?>

8. Functional recognition. The function supports the default value in the PHP, which is the same as the C ++ style.

<?
functionmakecoffee($type=”coffee”){

echo”makingacupof$type.\n”;
}
echomakecoffee();//”makingacupofcoffee”
echomakecoffee(“espresso”);//”makingacupofespresso”
/*
Note: When the default value of the parameters is used, all parameters with the default value should be defined behind the parameters without silence. Otherwise, the program will not follow what you want.
*/

functiontest ($ type = “test”, $ ff) {// error example
return$type.$ff;
}

9. Several special symbols of PHP.

$ variable
& Variable Address (Add in front of the variable)
@3 3 3 3 3 (plus in front of the variable)
-> Class method or attribute
=> The elemental value of the array
?: Ternary operator

10, include () statement and Require () statement

If you need to include files according to conditions or circulation, you need to use include ().

Require () statement is just included by simply, any conditional statement or cycle is invalid.

Since include () is a special statement structure, if the statement is in a statement block, he must include him in a statement block.

<?
// The following is a wrong sentence
if($condition)
include($file);
else
include($other);

// The correct statement below
if($condition){

include($file);
}else
{

include($other);
}
?>

Reprinted: https://www.cnblogs.com/yaojing/archive/2009/10/17/1584874.html

source

Related Posts

java-Java.sql.sqlexception: Unable to load authentication plugin ‘cachingSha2Password‘.

Linux MySQL login anomaly Error 1045 (28000): Access Denied for User ‘ROOT’@’LocalHost’ (USING Password: Yes)

Springer LNCS Latex Submission Template How to use TO USE The Springer LNCS Latex Template

Sorting Algorithm-Base Sorting-Detailed Explanation and Code Analysis

The traffic of port 80 was forwarded to 192.168.0.1

Random Posts

django sending email failed

python framework Django2 tutorial (1)

Center 7 deploy mysqlkevin

CSUOJ: Training Team Team Plan

IDEA import project but cannot load the jar package dependent on the pom.xml file