1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
<?php
/**
* GitHub Issue: https://github.com/emacs-php/php-mode/issues/136
*
* The code below contains strings with interpolated variables. PHP
* Mode must use font-lock-variable-name-face to highlight all of
* those variables. The page
*
* http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
*
* describes all of the variable syntaxes which PHP Mode must
* recognize and highlight appropriately.
*
*/
$name = "Eric";
class User
{
public $name;
public $id = 0;
public function getName()
{
return $this->name;
}
public function getID()
{
return $this->id;
}
}
$user = new User();
$user->name = "Eric";
$users = array($user);
$index = 0;
ob_start();
echo "My name is $name";
echo "My name is ${name}";
echo "My name is {$name}";
echo "My name is {$user->name}";
echo "My name is {$user->getName()}";
echo "My name is {$users[0]->name}";
echo "My name is {$users[$index]->name}";
echo "My name is {$users[$user->id]->name}";
echo "My name is {$users[$user->getID()]->name}";
ob_end_clean();
|