【问题标题】:php 5.3 ereg_replace to preg_replacephp 5.3 ereg_replace 到 preg_replace
【发布时间】:2012-10-01 20:05:49
【问题描述】:
$this->Settings = array( "host" => $host , "user" => $user , "pass" => $pass );
    $this->db = $db;
    $this->Settings["name"] = ereg_replace  ("_", "", $this->db);
    $this->init();

我有一个应用程序在从 php 5.2 迁移到 php 5.3 后无法运行。

即使我将上面的 ereg_replace 行更改为

$this->aSettings["name"] = preg_replace("/_/", "", $this->db);

它仍然没有从数据库中获取设置。

【问题讨论】:

  • 如果问题是没有从数据库中检索到值,那么问题出在您的 $db 变量中。尝试检查它的值:var_dump($db)

标签: php preg-replace ereg-replace


【解决方案1】:

您的preg_replace() 不起作用并没有特别的原因,但您可以简单地使用str_replace()

$this->Settings['Name'] = str_replace('_', '', $this->db);

这句话让我很感兴趣:

$this->db = $db;

$db 设置在哪里?沿着这条路走,直到找到真正的问题所在,

【讨论】:

  • 谢谢。是的。。这不是问题。即使将错误报告设置为全部,也很难跟踪,因为没有错误。
  • @PotentialCoder 那你需要分享更多你的代码,否则无法帮助你。
猜你喜欢
  • 2011-01-27
  • 1970-01-01
  • 2012-03-09
  • 2012-01-28
  • 2011-09-10
  • 2013-07-17
  • 1970-01-01
  • 2013-08-06
  • 2012-11-16
相关资源
最近更新 更多