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
PLease clarify T_STRING error meaning
Moderator: General Moderators
- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
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.
$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.