0

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?

11
  • $LANG["create_new_ticket"] or $LANG['create_new_ticket'] enclose the key with single quote or double quote. for numeric key enclosing is not necessary, but for string key, you need to add up quotes. Commented Jan 23, 2016 at 9:18
  • This isn't anything to do with "compliance" between versions of PHP.... it's simply to do with the error reporting levels that you have configured on your servers.... this has always issued a notice, but you've disabled displaying notices before now Commented Jan 23, 2016 at 9:19
  • Done , but the warning/error is still there Commented Jan 23, 2016 at 9:26
  • What warning/error? You only had notices before Commented Jan 23, 2016 at 9:28
  • Ok same "notices" e.g. Notice: Use of undefined constant create_new_ticket - assumed 'create_new_ticket' . I've tried bot ['xx'] and ["xx"] Commented Jan 23, 2016 at 9:29

3 Answers 3

2

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";
Sign up to request clarification or add additional context in comments.

3 Comments

Hello Mureinik, I've done the modification but the Notices are still there, can you guess why? Is it matter of something else in the script? Thank you for the replies
You probably need to apply the same fix on other lines as well. Check the line numbers in the notices you get.
Unfortunately they are still all the lines :-( and in all th elines, one for each sentence, they are now ['x']
0

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",
];

4 Comments

No way, I did it and it throws the same notice , this is making me crazy :-). I suspect now some variables are not passed anymore among the scripts and includes. In fact I notice that also the db connection fails so the db_connect script is not passing the variables anymore "Notice: Undefined variable: db_user"
Have you tried to check the php logs for further details?
Ok, I got it, they are the includes that don't pass the variables.
Ciao Fabrizio, thank you for your assistance, the php log shows the same output as the browser. I've erased the log and refreshed the page, this is the new log jpst.it/E-2F
0

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

1 Comment

Ciao Filippo, as written to Fabrizio, looks like these scripts in php 5.6 are not passing the variables of the others php includes files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.