Home Backend Development PHP Tutorial Detailed explanation of php5 and mysql5 web development technology-3 variables, expressions and constants_PHP tutorial

Detailed explanation of php5 and mysql5 web development technology-3 variables, expressions and constants_PHP tutorial

Jul 14, 2016 am 10:08 AM
php5 web and Classification variable name and definition constant Development Technology expression Detailed explanation

1. Definition, naming and classification

Divided into three types: scalar variables, array variables and objects
2. Printing and output variables
echo statement
printf() function
          Example: :
                                                                        printf("%d bootles of beer on %s", 100, "the wall");
printf("The %2$s likes to %1$s", "bark","dog");
sprintf() function
Example:
$formatted= fprintf("%01.2f",$var);
3. Display arrays and objects
print_r(array and variable);
var_dump (array variable object)
var_export (array variable object) The representation of the variable can be returned by setting parameters
          Example:
 $v = var_export($a,true); //Return the source code of php and use it directly in the array of php script
4. Data types supported by php variables
Integer, double, character, Boolean
Array, object, resource(Resource)
NULL
There are two ways to quote strings: double quotes and single quotes
Get and set variable type: gettype()/settype()
Arrays and objects are called conforming data types
5. Variables of variables
$var_name = 'php5';
$$var_name = ''php5 web development details;
echo $php5;
6. Super global variable array
$_GET[]
$_POST[]
$_COOKIE[]
$_SESSION[]
$_ENV[]
$_SERVER[]
$_FILES[]
$_REQUEST[]
$_GLOBALS[]
7. Variable operator
There is a lot of content, only the categories are listed without specific enumeration.
Arithmetic
Assignment
String concatenation
Pre and post addition and subtraction
Reference & After reference assignment, the variables have the same memory address
Ternary operator
Comparison operation
Boolean operator
Bit operator
Other operators:
1. Error suppression @
2. External command execution
                    $out = ·dir c:·
                      print_r($out);  
                    $our = shell_exec("dir");
echo $out;
The results of the two functions are the same, and the result is placed in a array; shell_exec () method puts the result in a scalar variable
8. Variable and script processing
isset()
unset()
empty()
is_array()is_integer()is_numeric()
9. Data conversion
Force type conversion of variables:
(array)
(bool)/(boolean)
(int)
(object)
(real)/(double)/(fload)
(string)
Others:
(1)intval($var):
(2)HereDoc
HereDoc allows embedding some large text content in php, such as email templates or some html or text content.
$string = 'hello';
$output = <<
The value of $string in HEREDOC is $string
MYDOC
echo $output;
The output result is: the value of $string in HEREDOC is hello
(3) escape character
n, t , \ ,$ ,''
(4) Numeric conversion function
chr($var) : Return the corresponding ASCII character according to the value of $var;
ord($string) returns the ASCII code value of the first character of the string;
10. Constant definition and magic constants
define("CONSTANT_NAME", constant value)
__LINE__
__FILE__
__FUNCTION__
__CLASS__
__METHOD__

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477716.htmlTechArticle1. Definition, naming and classification are divided into three types: scalar variables, array variables and objects 2. Printing and output Variable echo statement printf() function example: printf(%d bootles of beer on...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of obtaining administrator rights in Win11 Detailed explanation of obtaining administrator rights in Win11 Mar 08, 2024 pm 03:06 PM

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in Oracle SQL Detailed explanation of division operation in Oracle SQL Mar 10, 2024 am 09:51 AM

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

The definition and function of MySQL composite primary key The definition and function of MySQL composite primary key Mar 15, 2024 pm 05:18 PM

The composite primary key in MySQL refers to the primary key composed of multiple fields in the table, which is used to uniquely identify each record. Unlike a single primary key, a composite primary key is formed by combining the values ​​of multiple fields. When creating a table, you can define a composite primary key by specifying multiple fields as primary keys. In order to demonstrate the definition and function of composite primary keys, we first create a table named users, which contains three fields: id, username and email, where id is an auto-incrementing primary key and user

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

What is Discuz? Definition and function introduction of Discuz What is Discuz? Definition and function introduction of Discuz Mar 03, 2024 am 10:33 AM

"Exploring Discuz: Definition, Functions and Code Examples" With the rapid development of the Internet, community forums have become an important platform for people to obtain information and exchange opinions. Among the many community forum systems, Discuz, as a well-known open source forum software in China, is favored by the majority of website developers and administrators. So, what is Discuz? What functions does it have, and how can it help our website? This article will introduce Discuz in detail and attach specific code examples to help readers learn more about it.

Detailed explanation of the role and usage of PHP modulo operator Detailed explanation of the role and usage of PHP modulo operator Mar 19, 2024 pm 04:33 PM

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

Introduction to PHP interfaces and how to define them Introduction to PHP interfaces and how to define them Mar 23, 2024 am 09:00 AM

Introduction to PHP interface and how it is defined. PHP is an open source scripting language widely used in Web development. It is flexible, simple, and powerful. In PHP, an interface is a tool that defines common methods between multiple classes, achieving polymorphism and making code more flexible and reusable. This article will introduce the concept of PHP interfaces and how to define them, and provide specific code examples to demonstrate their usage. 1. PHP interface concept Interface plays an important role in object-oriented programming, defining the class application

How to enable administrative access from the cockpit web UI How to enable administrative access from the cockpit web UI Mar 20, 2024 pm 06:56 PM

Cockpit is a web-based graphical interface for Linux servers. It is mainly intended to make managing Linux servers easier for new/expert users. In this article, we will discuss Cockpit access modes and how to switch administrative access to Cockpit from CockpitWebUI. Content Topics: Cockpit Entry Modes Finding the Current Cockpit Access Mode Enable Administrative Access for Cockpit from CockpitWebUI Disabling Administrative Access for Cockpit from CockpitWebUI Conclusion Cockpit Entry Modes The cockpit has two access modes: Restricted Access: This is the default for the cockpit access mode. In this access mode you cannot access the web user from the cockpit

See all articles