Array problems?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MortiKahn
Forum Newbie
Posts: 2
Joined: Sun Jul 28, 2002 5:39 am

Array problems?

Post by MortiKahn »

PHP Version 4.0.4pl1
ok here is the problem...
in the file
/languages/english/generic.php
the following array is defined
--------------------------------------------------------------------------------
$lang[THIS_FILE] = 'english'
$lang[NEW_POST_ICON] = "Post";
$lang[PREV_ICON] = "Previous";
$lang[INDEX_ICON] = "Index";
$lang[NEXT_ICON] = "Next";
$lang[EXP_ICON] = "Expand";
$lang[COL_ICON] = "Collapse";
$lang[FLAT_ICON] = "Flat";
$lang[THREAD_ICON] = "Threaded";
$lang[EDIT_ICON] = "Edit";
$lang[REPLY_ICON] = "Reply";
$lang[FORUM_RETURN] = "Return to Forum";
...
$lang[DELETE_CHECK] = "Delete checked";
--------------------------------------------------------------------------------
This is from a working website, I simply copied all the files over to a new location, in order to do some beta work on a new design.

The problem seems to be in the new instance, located at gccbeta.gameclubcentral.com/forums.
altho the 2 files are identical, when echoing the array $lang[THIS_FILE] you get 'D'.
--------------------------------------------------------------------------------
Fatal error: Failed opening required 'languages/D/ubbthreads.php' (include_path='.:/usr/local/lib/php')
--------------------------------------------------------------------------------

Notice the D. that should read
'english'

echo $lang; #by itself, no array []
results in
Dnglish
If you go in to generic.php and change the last line to read something other than "Delete checked" , say "PHP" then the error lines reads

--------------------------------------------------------------------------------
required 'languages/P/ubbthreads.php'
--------------------------------------------------------------------------------

site 1 functions normally, site 2 functions normally, site 3 functions normally, site 4 has this error.
I can not get another instance to work at all. Not under a current url, not under a new url. Any thoughts or suggestions are appreciated. thanks
MortiKahn
Forum Newbie
Posts: 2
Joined: Sun Jul 28, 2002 5:39 am

Post by MortiKahn »

some more testing
var_dump($lang);
results in
string(7) "Dnglish"

keep in mind absolutly no code was changed between instances.
gnu2php
Forum Contributor
Posts: 122
Joined: Thu Jul 11, 2002 2:53 am

Post by gnu2php »

when echoing the array $lang[THIS_FILE] you get 'D'
I wonder if the problem is with the THIS_FILE constant. Maybe in old versions of PHP it is the same as __FILE__, which contains the name of the current file.

You might try changing the name of THIS_FILE to something like MY_FILE.

If that doesn't help, maybe it'll work if you use this kind of array structure:

Code: Select all

$lang = array(
	THIS_FILE => 'english',
	NEW_POST_ICON => "Post",
	PREV_ICON => "Previous",
	INDEX_ICON => "Index",
	NEXT_ICON => "Next",
	EXP_ICON => "Expand",
	COL_ICON => "Collapse",
	FLAT_ICON => "Flat",
	THREAD_ICON => "Threaded",
	EDIT_ICON => "Edit",
	REPLY_ICON => "Reply",
	FORUM_RETURN => "Return to Forum",
	...
	DELETE_CHECK => "Delete checked",
);
Finally, I don't know if it matters or not, but you seem to have forgotten the trailing semi-colon:

Code: Select all

$langїTHIS_FILE] = 'english'
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you should quote the hashes i.e. $lang['THIS_FILE'] = 'english' (of course unless you've declared all those constants)
Post Reply