PHP变量的变量——可变变量
来源:互联网 发布:淘宝购物车营销针对 编辑:程序博客网 时间:2024/04/20 01:03
PHP变量的变量,即可变变量
可变变量的概念:通过获取一个变量的值做为另外一个变量的名称来操作变量,就是可以变量。
【示例】
<?php
$a = 'hello'; //普通变量
$$a = 'world'; //可变变量 ,相当于 $hello='world';
echo "$a $hello"; //输出:hello world
echo $$a; //输出:world
echo "$a ${$a}"; //输出:hello world
echo "$a {$$a}"; //输出:hello world
?>
$a = 'hello'; //普通变量
$$a = 'world'; //可变变量 ,相当于 $hello='world';
echo "$a $hello"; //输出:hello world
echo $$a; //输出:world
echo "$a ${$a}"; //输出:hello world
echo "$a {$$a}"; //输出:hello world
?>
有时候使用可变变量是很方便的,就是一个可变变量获取了一个普通变量的值作为这个可变变量的变量名。
<?php
$var1="this is var1";
$var2="this is var2";
$a="var1";
echo $$a; //输出 this is var1
$a="var2";
echo $$a; //输出 this is var2
?>
$var1="this is var1";
$var2="this is var2";
$a="var1";
echo $$a; //输出 this is var1
$a="var2";
echo $$a; //输出 this is var2
?>
- PHP变量的变量——可变变量
- PHP的可变变量
- PHP的可变变量
- PHP的可变变量
- PHP的可变变量名
- PHP的可变变量名
- PHP的可变变量名
- PHP的可变变量名
- php可变变量的用法
- [PHP]可变变量||动态变量
- PHP变量的定义、可变变量、变量引用、销毁
- PHP 变量的声明、可变变量、引用变量
- php——学习笔记,可变变量
- php中有两个美元符号$$的变量——可变变量
- 23. PHP 可变变量
- PHP中的可变变量
- php 可变变量
- php 可变变量实例
- 关于ireport脚本的我自己的一部分总结
- OneNote and Autohotkey – Useful Scripts
- PMD规则之Type Resolution Rules
- 用Nohup命令让Linux下的程序在后台执行
- PMD规则之Unused Code Rules
- PHP变量的变量——可变变量
- 如何用标准的odbc sql接口访问wincc归档数据库
- 闲谈
- Smary模板应用30分钟入门教程
- C++中传值参数和引用参数和指针怎样区别?
- 非对称加密算法
- linux常用命令
- extern 使用方法
- QT下int与QByteArray的转换