What does a \ (backslash) do in PHP (5.3+)?
\
(backslash) is the namespace separator in PHP 5.3.
A \
before the beginning of a function represents the Global Namespace.
Putting it there will ensure that the function called is from the global namespace, even if there is a function by the same name in the current namespace.
Backslash in PHP -- what does it mean?
It's because they're using PHP namespaces. Namespaces are new as of PHP 5.3.
What does backslash do as prefix to a function name?
Introduced in PHP 5.3, \
is a namespace separator.
In your example, the outer strlen is MyFramework\MyString\strlen, the inner strlen is the global one.
Without any namespace definition, all class and function definitions are placed into the global space - as it was in PHP before namespaces were supported. Prefixing a name with \ will specify that the name is required from the global space even in the context of the namespace.
Reference: http://www.php.net/manual/en/language.namespaces.global.php
I don't understand why backslash is used in extends class in php code
It is used to let PHP know where the class exists. For example, \app\classes\TestClass
will let it know that the class exists in app\classes
directory/namespace. If you will not add the path, It will look for the class in the same Namespace!
PHP 5.3 Namespaces should i use every PHP function with backslash?
No matter the performance hit, no way should you do that. Ew, ew, ew. Any performance boost there may be is not worth your sanity.
What is the backslash in `new \SendGrid(...` within PHP?
\
(backslash) is the namespace separator in PHP 5.3.
A \
before the beginning of a function represents the Global Namespace.
Putting it there will ensure that the function called is from the global namespace, even if there is a function by the same name in the current namespace.
[ Reference: What does a \ (backslash) do in PHP (5.3+)? ]
What does mean if (\false) (yes, with backslash) in PHP?
It means it's using the false defined in the global namespace..
After a bit of research it turns out the rest of this answer is nonesense... I could swear you were able to do this in PHP at one point in time.
I think this is get around the situation where
<?php
namespace whywouldyoudothis;
false = true;
?>
I have never ever seen anyone code for this but that's what springs to mind.
Related Topics
Using Jquery $.Ajax to Call a PHP Function
Single Result from Database Using MySQLi
How to Check If an Email Address Exists Without Sending an Email
Apache Shows PHP Code Instead of Executing It
What Is the Most Accurate Way to Retrieve a User'S Correct Ip Address in PHP
Asynchronous Shell Exec in PHP
How to Read a Large File Line by Line
Apache Is Downloading PHP Files Instead of Displaying Them
How to Extract Img Src, Title and Alt from HTML Using PHP
How to Convert an Array to Object in PHP
How to Create a Comma-separated List from an Array in PHP
Permutations - All Possible Sets of Numbers
Convert Time in Hh:Mm:Ss Format to Seconds Only
How to Store Repeating Dates Keeping in Mind Daylight Savings Time