PHP中基本符号及使用方法_PHP
用这么久了,竟然PHP的基本符号都没有认全,看到@号还查了半天才知道什么意思.把基本符号列表帖一下吧,需要的朋友可以参考~
注解符号:
// 单行注解 /* */ 多行注解 |
引号的使用
’ ’ 单引号,没有任何意义,不经任何处理直接拿过来; " "双引号,php动态处理然后输出,一般用于变量. |
变量形态:
一种是True 即 真的; 另一种是False 即假的 |
常见变量形态:
string 字串(数字\汉字\等等) integer 整数(1、2、3、4、5、0、-1、-2、等等) double 浮点数(小数点) array 数组 object 对象 |
可以用的方法有gettype($mix) 和settype($mix,$typename);
常用符号
\" 双引号 \\ 反斜线 \n 换行 \r 送出 \t 跳位(TAB) |
运算符号
+ 加法运算 - 减法运算 * 乘法运算 / 除法运算 % 取余数 ++ 累加 -- 累减1 . 把字串相加 |
设定运算
= 把右边的值代入左边(一定要会) += 把右边的值加到左边 -= 把右边的值减到左边 *= 把左边的值乘以右边 /= 把左边的值除以右边 .= 把右边的字串加到左边 |
位员运算
& 且 | 或 ^ 互斥(xor) >> 向右移位 ~ 取1的补数 |
逻辑运算
大于 = 大于等于 != 不等于 && 而且 || 或者 ! 不 |
其他运算符号
$ 变量符号 & 变量的指标(加在变量前) @ 不显示错误信息(加在函数前) -> 对象的方法或者属性 => 数组的元素值 ? : 三元运算子 |
基本方法
1.PHP转换字符串为大小写!
strtolower(); 把字符转小写 strtoupper(); 把字符转大写 |
2.PHP加密字符串(大小写均可)
md5();加密 sha1();加密 |
3.关于引号
一、单引号是原样输出
二、双引号是内容解释进行输出
三、反单引号是执行一个命令,如`pwd`。
四、“\”作用于转译字符,如“\n”为换行!
4.函数:htmlspecialchars()
本函数将特殊字符转成 HTML 的字符串格式 ( &....; )。最常用到的场合可能就是处理客户留言的留言版了。
& (和) 转成 & " (双引号) 转成 " > (大于) 转成 > |
此函数只转换上面的特殊字符,并不会全部转换成 HTML 所定的 ASCII 转换。

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



Environment variables are the path to the location (or environment) where applications and programs run. They can be created, edited, managed or deleted by the user and come in handy when managing the behavior of certain processes. Here's how to create a configuration file to manage multiple variables simultaneously without having to edit them individually on Windows. How to use profiles in environment variables Windows 11 and 10 On Windows, there are two sets of environment variables – user variables (apply to the current user) and system variables (apply globally). However, using a tool like PowerToys, you can create a separate configuration file to add new and existing variables and manage them all at once. Here’s how: Step 1: Install PowerToysPowerTo

In iOS17, Apple has added several new features to its Messages app to make communicating with other Apple users more creative and fun. One of the features is the ability to use emojis as stickers. Stickers have been around in the Messages app for years, but so far, they haven't changed much. This is because in iOS17, Apple treats all standard emojis as stickers, allowing them to be used in the same way as actual stickers. This essentially means you're no longer limited to inserting them into conversations. Now you can also drag them anywhere on the message bubble. You can even stack them on top of each other to create little emoji scenes. The following steps show you how it works in iOS17

Strict mode was introduced in PHP7, which can help developers reduce potential errors. This article will explain what strict mode is and how to use strict mode in PHP7 to reduce errors. At the same time, the application of strict mode will be demonstrated through code examples. 1. What is strict mode? Strict mode is a feature in PHP7 that can help developers write more standardized code and reduce some common errors. In strict mode, there will be strict restrictions and detection on variable declaration, type checking, function calling, etc. Pass

Instance variables in Java refer to variables defined in the class, not in the method or constructor. Instance variables are also called member variables. Each instance of a class has its own copy of the instance variable. Instance variables are initialized during object creation, and their state is saved and maintained throughout the object's lifetime. Instance variable definitions are usually placed at the top of the class and can be declared with any access modifier, which can be public, private, protected, or the default access modifier. It depends on what we want this to be

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

Python is widely used in a wide range of fields with its simple and easy-to-read syntax. It is crucial to master the basic structure of Python syntax, both to improve programming efficiency and to gain a deep understanding of how the code works. To this end, this article provides a comprehensive mind map detailing various aspects of Python syntax. Variables and Data Types Variables are containers used to store data in Python. The mind map shows common Python data types, including integers, floating point numbers, strings, Boolean values, and lists. Each data type has its own characteristics and operation methods. Operators Operators are used to perform various operations on data types. The mind map covers the different operator types in Python, such as arithmetic operators, ratio

Detailed explanation and code examples of const in C In C language, the const keyword is used to define constants, which means that the value of the variable cannot be modified during program execution. The const keyword can be used to modify variables, function parameters, and function return values. This article will provide a detailed analysis of the use of the const keyword in C language and provide specific code examples. const modified variable When const is used to modify a variable, it means that the variable is a read-only variable and cannot be modified once it is assigned a value. For example: constint

jQuery is a JavaScript library widely used in web development. It provides many simple and convenient methods to operate web page elements and handle events. In actual development, we often encounter situations where we need to determine whether a variable is empty. This article will introduce several common methods of using jQuery to determine whether a variable is empty, and attach specific code examples. Method 1: Use the if statement to determine varstr="";if(str){co
