PLease clarify T_STRING error meaning

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
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

PLease clarify T_STRING error meaning

Post by rfigley »

As I'm developing this site. (Learning as I go) I get a number of repeating errors as I test my code which I don't understand. One of which is unexpected or expected T_STRING..... What is a T_STRING? I'm guessing this is a syntax error, but understading it better would be helpul.

Thanks
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Can you post the full error message and the source code for the line its appearing on? (The first occurence is probably the most useful for debugging if the error occurs multiple times.)
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

Often times this occurs when you have this scenario:

$me = array('first_name' => 'Bob');
echo "Hello there, my name is $me['first_name']";

This will produce that same error that you encountered. There are 2 ways to fix it:

echo "Hello there, my name is {$me['first_name']}";

OR

echo "Hello there, my name is ".$me['first_name'];

I prefer the first method, but both will work.
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

yeah, I always get this message when I forget to put braces around an array variable in a double-quoted string.
Post Reply