Reputation: 508
I have this script that fills the array but the php I understand is not compliant with 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";
/?>
but this way throws as a many
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
which is the correct syntax?
Upvotes: 0
Views: 75
Reputation: 3775
That's the way I've always declared an associative array:
$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");
See Official PHP docs You can also a working snippet
Upvotes: 0
Reputation: 1909
Try with array declaration as per PHP docs.
$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",
];
Upvotes: 0
Reputation: 311373
The keys you're using should also be strings, not bare words:
$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";
Upvotes: 2