Re: unexpected T_STRING error
| From: | Philip Olson | Date: | Sat, 28 Sep 2002 18:55:48 +0000 |
| Subject: | Re: unexpected T_STRING error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117968@lists.php.net to get a copy of this message | ||
You can mix and match single (') and double (")
quotes so the following are all appropriate:
echo "a 'string' b";
echo "a \"string\" b";
echo 'a \'string\' b";
echo 'a "string" b";
See? PHP can't read your mind and know what "
goes with what, like:
echo "a"b"c"d"e"f"g"; // BAD
Now, when dealing with arrays inside strings:
echo "an {$array['key']} b";
echo 'an ' . $array['key'] . ' b';
echo "an $array[key] b";
See also:
http://www.zend.com/zend/tut/using-strings.php
http://www.php.net/manual/en/language.types.string.php
Regards,
Philip Olson
On Sat, 28 Sep 2002, Gary wrote:
> Hi All,
> Can someone explain to me why I am getting an error for the following?
>
> $keywords = $_POST[keywords];
> if ($keywords) {
> echo"<META NAME="keywords" CONTENT=" $keywords
> ">";
> }
>
> TIA
> Gary
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>