【1】变量的间接引用:
<?php $a = 'b'; $$a = '123'; echo $b; ?>
上面的输出结果是123
我们可以看到在第二行代码中多了一个$,并通过指定的名称访问变量,指定的名字存储在$a('b')中,并把这个变量$b的值更改为123。因此,这样的$b的变量被创建和赋值。
通过在变量的前面增加附加的$标记,你可以任意增加引用的次数。
【2】连接字符串:通过连接运算符即句点(. )英文状态下的,把字符串连接起来,变成合并的新字符串。
<?php $a = 'PHP5' ; $b = '功能强大' ; echo $a.$b; ?>
为了让我们更加了解连接字符串,我们在上面的例子的基础上改变下,变成这个样子(PHP5: 功能强大 2014)
在这个例子中我们发现添加了引号、空格和数字。下面我们就用2种方法来写,具体差别自己发现把:
<?php $c = $a.': '.$b.' 2014'; $c = $a.': '.$b.' '.2014; ?>
【3】连接赋值运算符:如果只把一个值连接到另一个值,则可以使用连接赋值运算符(.= )。下面两条语句是等价的:
<?php $title = $title . $subtitle; $title .= $subtitle; ?>

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

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.