2016-01-23 50 views
0

我有此腳本,填補了數組,但據我所知,PHP是不符合5.6陣列轉換爲5.6

<?php 
$LANG = array(); 

$LANG[create_new_ticket] = "Create New Ticket"; 
$LANG[ticket_created] = "Your ticket has been created. An email has been sent to you containing the ticket information. If you would like to view your ticket and/or attach files you can do so: <a href=\\\"{\$HD_URL_TICKET_VIEW}?id=\$ticket&email={\$_POST[email]}\\\">\$ticket</a>"; 
$LANG[fill_in_form] = "To create a new support ticket, please fill out the form below."; 
$LANG[required_field] = "* Denotes a required field"; 

/?> 

但這種方式引發的許多

Notice: Use of undefined constant create_new_ticket - assumed 
'create_new_ticket' in D:\xampp\htdocs\tickets\lang\language.php on line 4 

Notice: Use of undefined constant ticket_created - assumed 
'ticket_created' in D:\xampp\htdocs\tickets\lang\language.php on line 5 

Notice: Use of undefined constant fill_in_form - assumed 
'fill_in_form' in D:\xampp\htdocs\tickets\lang\language.php on line 6 

Notice: Use of undefined constant required_field - assumed 
'required_field' in D:\xampp\htdocs\tickets\lang\language.php on line 7 

這是正確的語法?

+0

$ LANG [ 「create_new_ticket」]或$ LANG [」 create_new_ticket']用單引號或雙引號括住密鑰。對於數字鍵的括號不是必需的,但對於字符串鍵,則需要加上引號。 – ameenulla0007

+0

這與PHP版本之間的「遵從性」沒有任何關係......這只是與您在服務器上配置的錯誤報告級別有關......這始終發佈通知,在此之前已禁用顯示通知 –

+0

Ouch。謝謝 – Robert

回答

2

的鑰匙你使用也應該是字符串,而不是裸露的話:

$LANG['create_new_ticket'] = "Create New Ticket"; 
$LANG['ticket_created'] = "Your ticket has been created. An email has been sent to you containing the ticket information. If you would like to view your ticket and/or attach files you can do so: <a href=\\\"{\$HD_URL_TICKET_VIEW}?id=\$ticket&email={\$_POST['email']}\\\">\$ticket</a>"; 
$LANG['fill_in_form'] = "To create a new support ticket, please fill out the form below."; 
$LANG['required_field'] = "* Denotes a required field"; 
+0

完成,但警告/錯誤仍然存​​在 – Robert

+0

Hello Mureinik,已經做了修改,但通知仍然存在,你能猜出原因嗎?腳本中是否有其他內容?謝謝您的回覆 – Robert

+1

您可能還需要在其他行上應用相同的修補程序。在你得到的通知中。 – trincot

0

嘗試用數組聲明按照PHP文檔。

$LANG = [ 
    "create_new_ticket" => "Create New Ticket", 
    "ticket_created" => "Your ticket has been created. An email has been sent to you containing the ticket information. If you would like to view your ticket and/or attach files you can do so: <a href=\\\"{\$HD_URL_TICKET_VIEW}?id=\$ticket&email={\$_POST[email]}\\\">\$ticket</a>", 
    "fill_in_form" => "To create a new support ticket, please fill out the form below."; 
    "required_field" => "* Denotes a required field", 
]; 
+0

沒辦法,我做到了,它引發了同樣的通知,這讓我瘋狂: - )。我懷疑現在有些變量在腳本中不再被傳遞,並且包含在內。事實上我注意到db連接也失敗了,所以db_connect腳本不再傳遞這些變量了「注意:未定義的變量:db_user」在PHP 5.2.9中使用 – Robert

+0

,這就像一個魅力 – Robert

+0

你是否試圖檢查php日誌細節? –

0

這就是我一直宣稱的關聯數組方式:

$LANG = array(
"create_new_ticket" => "Create New Ticket", 
"ticket_created" => "Your ticket has been created. An email has been sent to you containing the ticket information. If you would like to view your ticket and/or attach files you can do so: <a href='{$HD_URL_TICKET_VIEW}?id={$ticket}&email={$_POST['email']}'>{$ticket}</a>", 
"fill_in_form" => "To create a new support ticket, please fill out the form below.", 
"d_field" => "* Denotes a d field"); 

Official PHP docs 您還可以工作snippet

+0

Ciao Filippo,寫到Fabrizio,看起來像這些腳本在PHP 5.6中沒有傳遞變量其他PHP包括文件 – Robert