douba3943 2010-02-04 21:32
浏览 15

PHP变量问题!

So I have a PHP variable that's value get's replaced from another PHP file. Example:

$var = "~~~OtherVariable~~~";

If I echo this variable out, it prints out the appropriate string. Example:

echo $var; //prints out "This is a string of text";

So it looks like everything is working thus far, my PHP variable ($var) shows that it actually contains the string "This is a string of text" and not "~~~OtherVariable~~~".

Now here comes the problem, I want to use this PHP variable in another PHP function I have else where (on the same page), I want the variables ($var) value to be "This is a string of text", but instead the function is reading it as "~~~OtherVariable~~~", which is not what I want!

Is there a way to make the function read the variable as "This is a string of text" instead of "~~~OtherVariable~~~"??

Thanks Guys & Gals

EDIT: Here's the chunk of code:

$string = "~~~ItemTitle~~~"; /*Another php file looks for any string in 
this file with "~~~ItemTitle~~~" and replaces it with another block of 
text, ie. "This is a string of text, http://www.google.ca" */

//Then I have a little function to look for any links inside of a string of text
function do_reg($text, $regex)
{
   preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER);
   return $result[0];
}

$regex = '\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]';

$regex = '$'.$regex.'$i';

$A =do_reg($string, $regex); /* This is where I tell it what string I want 
it to look into for any URL's */
foreach($A as $B)
{
   echo "$B<BR>"; //Prints out just the URL
}

But when I tell it too look in the $string variable it reads it as "~~~ItemTitle~~~" and not the string of text it gets replaced as.

  • 写回答

5条回答 默认 最新

  • dovhpmnm31216 2010-02-04 21:35
    关注

    Make it global? Not really sure what your asking.

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备