note 28813 deleted from language.types.string by colder

From: Date: Tue, 17 Oct 2006 17:56:26 +0000
Subject: note 28813 deleted from language.types.string by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-118630@lists.php.net to get a copy of this message
Note Submitter: Jeff at jsgennusa at yahoo dot com ---- This is why this is right: $beer = 'Heineken'; echo "$beer's taste is great"; // works, "'" is an invalid character for varnames echo "He drank some $beers"; // won't work, 's' is a valid character for varnames echo "He drank some ${beer}s"; // works In all these examples, the php code is looking for the variable $beer. In the first one, it works because when it finds $beer's it actually finds $beer and stops at the '. In the second one, it doesn't work because there is no variable designated as $beers. The third one works because the php code reads { and } as specifying what the actually variable is that it should be looking for. The { and } allow you to add onto the variable.

« previous php.notes (#118630) next »