dtjo87679 2012-10-10 20:56
浏览 29
已采纳

变量作为PHP中变量名称的一部分

Here are the variables:

$fake= 'cool';
$fake1 = 'not cool';
$hope= '1';

The idea is to combine $fake and the $hope to create the variable $fake1. The idea is that if the $hope variable was randomized it could generate a random variable: $fake1, $fake2, $fake3, etc. Right now I either get an error or just the values of $fake and $hope next to each other not the new variable.

  • 写回答

3条回答 默认 最新

  • duanlian1320 2012-10-10 21:03
    关注

    Ben's comment above does probably exactly what you're looking for, but if you're in PHP5 you can also do something like:

     $varname = $fake . $hope;
     $$varname = "horray";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥40 图书信息管理系统程序编写
  • ¥15 7-1 jmu-java-m02-使用二维数组存储多元线性方程组
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题