


PHP notes - Java programmers understand PHP programs, phpjava programmers understand_PHP tutorial
PHP Notes - Java programmers understand PHP programs, phpjava programmers understand
1. php is a A server-side scripting language, a loosely typed language.
2. ?> >
Script style >
Short style <% >ASPStyle
ends with ;; 3.
Note:a)
// b)
# c)
/* */
4. Variables are containers for storing data and are case-sensitive. When the variable is very long, use the delimiter <<<.
$k=<<
…
str;
I think PHP is a loosely typed language, so there is no specific type when variables are declared. Type keyword.
$ Variable name
1. must be letters or _begins
2. can only contain alphanumeric characters and underscores
3.
5. PHP is declared anywhere in the script.
6. Quoted/ Script used - scope
a) local(local ) b) global(global ) c) static(static ) Variables declared outside the function have global scope and can only be outside the function for a visit. Variables declared inside a function have local scope and can only be used within the function access. Function internal callglobalVariables need to be used internally global keywords are declared; ②$GLOBAL[index] All global variables are stored in , which can be obtained through the super global variable $GLOBAL[index]. 7. $GLOBAL[index]This array is accessible within the function and can be used to directly update global variables. 8. Usually, when the function completes execution, all variables are deleted. If you do not need to delete it, you need to use static 9. Constant None$ , cannot be changed in script. Pass define("The name of the constant","The value of the constant”,”Whether the constant name is case-sensitive”);true(Same case)Insensitive, falseSensitive. To define constants in a class, use the const keyword. A constant that changes depending on where it is used becomes a magic constant. 1) __FILE__ Current folder 2) __LINE__ Current line number 3) __FUNCTION__ Current function name 4) __CLASS__ Current class name 5) __METHOD__ The method name of the current object 10. Print: echo can output more than one string. print can only output a string and always returns 1. 11. strlen();Retrieve the specified characters or text within the stringstrpos(); String concatenation uses ".", “.” must be followed by a space.
12. Super global variable:
a) $GLOBALS refers to all variables in the global scope.
b) $_SERVER Saves information about headers, paths and script locations.
c) $_REQUEST is used to collect HTML form submission data.
d) $_POST 🎜>Widely used to collect submissionsmethod=”post”The form data after the HTML form is also commonly used to pass variables.
e) $_GET 🎜> is used to collect submissionsHTML form (method="get") can also collect form data after URL< Data sent in 🎜>.
f) 🎜>Upload files from client computer to remote server.
g) Get the server-side environment parameters. (variables_order=EPGCS)
<<> H) $ _ cookie is used to retrieve the value of cookie.
i) is used to store information about a user session, or to change the settings of a user session. 13. The statement will get all the text that exists in the specified file /Code / tag and copy it to the file using the include/require statement.
a) require(static Loading ), when an error occurs, a fatal error will be generated and the script will stop.
b) include(dynamic Load ). When an error occurs, only a warning will be generated and the script will continue to execute.
c) require_once/include_once Contain the same page only once.
14. Array processing: $Array name['Key name'] to initialize the array; you can also use Array() Function to create an array.
count()Returns the length of the array.
Array traversal: foreach loop, use count()Get the length of the array and then use for;list()Language structure loop, only used for default numeric index ;each() returns key-value pairs.
while(list($key,$value)=each($array)){
}
foreach($array as $key => $value){
}
15. PHPMedium Objects are declared using the class keywords. Class attributes also have scopes. If you do not specify a scope, you can use var is modified. The difference between member methods and functions is that they can be modified with keywords. Constructor__contract,Destructor__destruct
16. ” Scope operator, can be used in Call constants, variables and methods in a class without instantiation;
"=>" Array member access symbol;
"->" Object member access symbol; "=&" Quote (alias); "=" Assignment. 17. $Variable name = new Class name([Parameters]); 🎜> instantiation;
$ Variable name->Member attribute = value; //Assign a value to the attribute;
$ Variable name->Member attributes; >Get attribute value;
$Variable name-> Member methods; >How to use;
18. mysql: General Use conn.php to encapsulate it, then use requireGo to the required page.
1) $conn = mysql_pconnect("localhost","root" ,"") or die(mysql_error());
mysql_select_db(“ Database name”,$conn);// Connect to the specified database.
3) mysql_query("set names utf8");
$sql = “”;
$resultSet = mysql_query($sql) or die (“Invalid query : ".mysql_error);//Returnsql statement result set;
6) while($v = mysql_fetch_array($resultSet)){
echo " Field name: ".$v['title']; 8) } 9) mysql_free_result($resultSet);//Close the result set; 10) mysql_close($conn);//Close connection

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

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 tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
