在vars PHP上配置引用

时间:2015-02-11 12:39:53

标签: php apache centos config quote

我是网站上的新人(嗨!),我遇到了一个我无法解决的问题。我寻找它但没有结果......我认为这是一个愚蠢的事情,但我无法找到解决方案。

我正在将系统(php)迁移到其他服务器(两者都是CentOS),我对php vars中的引号有问题

    example:
    --------
    $_GET[var]
    $db_reg[assoc]
    $array[value]
    define(NAME,'value')
    etc..

所有案例都可以修复为索引添加引号,但问题是我有数千个php文件,每行有数百万行,我无法逐个检查......这将需要两个生命一半。

在旧服务器中,它正常工作,但在新版本中,vars无法识别,显示PHP注意:

"Notice: Use of undefined constant XXXX - assumed 'XXXX in..."
(ej: $_POST[XXXX])

Apache或PHP上的任何配置是否可以在vars上识别或不识别(隐隐约约)?

两台服务器上的php版本是相同的,我检查了php.ini并且类似。

感谢您的帮助,先谢谢。

丹尼尔

2 个答案:

答案 0 :(得分:0)

猜猜你需要一些关于变量及其用法(使用数组时)和固定索引具体结构的信息

使用变量:

$array = array('hi', 'you', 'there');
$i = 1;
echo $array[$i]; // -> works and is **fine** (will output 'you')

// --------------------------------

$array = array('a' => 'hi', 'b' => 'you', 'c' => 'there');
echo $array['a']; // -> works and is **fine**
// note: in especially that case **NEVER** user bare-words like this: echo $array[a] for >> a << here is expected to be a constant which (mostly) does not exist !
// php is so fuzzy that it will mostly interpret around like insane and output you the desired value ('hi' in that case) but that was never meant to be! And should always be prevented. Thats the reason for you getting that notice... 

// So never do this:
echo $array[a]; 
// ... if >> a << is NOT a valid and available contant

重要(总结到这一点): 没有引号和美元的单词被认为是常量,您可能不会经常使用它们。在大多数情况下,您使用引号(如上所述)或实际变量(由$标识)作为访问数据结构/数组的索引

答案 1 :(得分:0)

您可以尝试编辑php.ini文件: 更改 的error_reporting = E_ALL 至 error_reporting = E_ALL&amp; 〜E_NOTICE 这将禁用所有通知,但不确定这是否会解决您的问题。如果这对您有用,请尝试告诉我们。