Viewed   122 times


$smarty =& SESmarty::getInstance();

What is the & for?



It passes by reference. Meaning that it won't create a copy of the value passed.

See: (See Adam's Answer)

Usually, if you pass something like this:

$a = 5;
$b = $a;
$b = 3;

echo $a; // 5
echo $b; // 3

The original variable ($a) won't be modified if you change the second variable ($b) . If you pass by reference:

$a = 5;
$b =& $a;
$b = 3;

echo $a; // 3
echo $b; // 3

The original is changed as well.

Which is useless when passing around objects, because they will be passed by reference by default.

Friday, August 26, 2022

50 in binary is 11 0010, shift right by 4 yields 11 which is equal to 3.

See PHP documentation and Wikipedia.

Friday, September 23, 2022

It's a shorthand for <?php echo $a; ?>.

It's enabled by default since 5.4 regardless of php.ini settings.

Wednesday, October 5, 2022

=> is the separator for associative arrays. In the context of that foreach loop, it assigns the key of the array to $user and the value to $pass.


$user_list = array(
    'dave' => 'apassword',
    'steve' => 'secr3t'

foreach ($user_list as $user => $pass) {
    echo "{$user}'s pass is: {$pass}n";
// Prints: 
// "dave's pass is: apassword"
// "steve's pass is: secr3t"

Note that this can be used for numerically indexed arrays too.


$foo = array('car', 'truck', 'van', 'bike', 'rickshaw');
foreach ($foo as $i => $type) {
    echo "{$i}: {$type}n";
// prints:
// 0: car
// 1: truck
// 2: van
// 3: bike
// 4: rickshaw
Sunday, November 6, 2022

It's a bitwise operator.


"hallo" ^ "hello"

It outputs the ASCII values #0 #4 #0 #0 #0 ('a' ^ 'e' = #4).

Monday, August 1, 2022

It's called an Alternative Syntax For Control Structures. You should have an endwhile; somewhere after that. Basically, it allows you to omit braces {} from a while to make it look "prettier"...

As far as your edit, it's called the Ternary Operator (it's the third section). Basically it's an assignment shorthand.

$foo = $first ? $second : $third;

is the same as saying (Just shorter):

if ($first) {
    $foo = $second;
} else {
    $foo = $third;
Saturday, October 8, 2022

${ } (dollar sign curly bracket) is known as Simple syntax.

It provides a way to embed a variable, an array value, or an object property in a string with a minimum of effort.

If a dollar sign ($) is encountered, the parser will greedily take as many tokens as possible to form a valid variable name. Enclose the variable name in curly braces to explicitly specify the end of the name.

$juice = "apple";

echo "He drank some $juice juice.".PHP_EOL;
// Invalid. "s" is a valid character for a variable name, but the variable is $juice.
echo "He drank some juice made of $juices.";
// Valid. Explicitly specify the end of the variable name by enclosing it in braces:
echo "He drank some juice made of ${juice}s.";

The above example will output:

He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
Thursday, October 13, 2022

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (

  -r, --register-only
        do not remove files, only register the packages as not installed

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022

3.3. HTTP

An HTTP URL takes the form:



   Within the <path> and <searchpart> components, "/", ";", "?" are
   reserved.  The "/" character may be used within HTTP to designate a
   hierarchical structure.

So as others mentioned it is only a reserved separator there.

This document updates the above (as DaveRandom mentions):

But I think the point is the same, and it is harder to quote from this newer version. :)

Friday, September 30, 2022

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :