Consider:
$smarty =& SESmarty::getInstance();
What is the &
for?
Consider:
$smarty =& SESmarty::getInstance();
What is the &
for?
50 in binary is 11 0010
, shift right by 4 yields 11
which is equal to 3.
See PHP documentation and Wikipedia.
It's a shorthand for <?php echo $a; ?>
.
It's enabled by default since 5.4 regardless of php.ini
settings.
=>
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
.
Example:
$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.
Example:
$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
It's a bitwise operator.
Example:
"hallo" ^ "hello"
It outputs the ASCII values #0
#4
#0
#0
#0
('a'
^ 'e'
= #4
).
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;
}
${ }
(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.
<?php $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.
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 (pecl.php.net)
Options:
...
-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).
http://www.ietf.org/rfc/rfc1738.txt
3.3. HTTP
An HTTP URL takes the form:
http://<host>:<port>/<path>?<searchpart>
...
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):
http://tools.ietf.org/html/rfc3986#section-3.4
But I think the point is the same, and it is harder to quote from this newer version. :)
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 ..
It passes by reference. Meaning that it won't create a copy of the value passed.
See: http://php.net/manual/en/language.references.php (See Adam's Answer)
Usually, if you pass something like this:
The original variable (
$a
) won't be modified if you change the second variable ($b
) . If you pass by reference:The original is changed as well.
Which is useless when passing around objects, because they will be passed by reference by default.