Skip to main content

Posts

Showing posts with the label php-atom

PHP Supported Protocols and Wrappers

Supported Protocols and Wrappers   PHP comes with many built-in wrappers for various URL-style protocols for use with the filesystem functions such as  fopen() ,  copy() ,  file_exists()  and  filesize() . In addition to these wrappers, it is possible to register custom wrappers using the  stream_wrapper_register()  function. Note :  The URL syntax used to describe a wrapper only supports the  scheme://...  syntax. The  scheme:/  and  scheme:  syntaxes are not supported. file://  — Accessing local filesystem http://  — Accessing HTTP(s) URLs ftp://  — Accessing FTP(s) URLs php://  — Accessing various I/O streams zlib://  — Compression Streams data://  — Data (RFC 2397) glob://  — Find pathnames matching pattern phar://  — PHP Archive ssh2://  — Secure Shell 2 rar://  — RAR ogg://  — Audio streams expect://  — Process Interaction Stre...

PHP Context Options and Parameters

Context options and parameters   PHP offers various context options and parameters which can be used with all filesystem and stream wrappers. The context is created with  stream_context_create() . Options are set with  stream_context_set_option()  and parameters with  stream_context_set_params() . Socket context options  — Socket context option listing HTTP context options  — HTTP context option listing FTP context options  — FTP context option listing SSL context options  — SSL context option listing CURL context options  — CURL context option listing Phar context options  — Phar context option listing MongoDB context options  — MongoDB context option listing Context parameters  — Context parameter listing Zip context options  — Zip context option listing

PHP Predefined Variables

Predefined Variables   PHP provides a large number of predefined variables to all scripts. The variables represent everything from external variables  to built-in environment variables, last error messages to last retrieved headers. See also the FAQ titled " How does register_globals affect me? " Superglobals  — Superglobals are built-in variables that are always available in all scopes $GLOBALS  — References all variables available in global scope $_SERVER  — Server and execution environment information $_GET  — HTTP GET variables $_POST  — HTTP POST variables $_FILES  — HTTP File Upload variables $_REQUEST  — HTTP Request variables $_SESSION  — Session variables $_ENV  — Environment variables $_COOKIE  — HTTP Cookies $php_errormsg  — The previous error message $HTTP_RAW_POST_DATA  — Raw POST data $http_response_header  — HTTP response headers $argc  — The number of arguments passed t...

PHP References

References Explained   What References Are What References Do What References Are Not Passing by Reference Returning References Unsetting References Spotting References

PHP Exceptions

Exceptions   Extending Exceptions PHP 5 has an exception model similar to that of other programming languages. An exception can be  throw n, and caught (" catch ed") within PHP. Code may be surrounded in a  try  block, to facilitate the catching of potential exceptions. Each  try  must have at least one corresponding  catch  or  finally  block. The thrown object must be an instance of the  Exception  class or a subclass of  Exception . Trying to throw an object that is not will result in a PHP Fatal Error. catch Multiple  catch  blocks can be used to catch different classes of exceptions. Normal execution (when no exception is thrown within the  try  block) will continue after that last  catch  block defined in sequence. Exceptions can be  throw n (or re-thrown) within a  catch  block. When an exception is thrown, code following the statement will not be execut...

PHP Errors

Errors   Basics Errors in PHP 7 Introduction   Sadly, no matter how careful we are when writing our code, errors are a fact of life. PHP will report errors, warnings and notices for many common coding and runtime problems, and knowing how to detect and handle these errors will make debugging much easier.

PHP Namespaces

Namespaces   Namespaces overview Defining namespaces Declaring sub-namespaces Defining multiple namespaces in the same file Using namespaces: Basics Namespaces and dynamic language features namespace keyword and __NAMESPACE__ constant Using namespaces: Aliasing/Importing Global space Using namespaces: fallback to global function/constant Name resolution rules FAQ: things you need to know about namespaces

PHP Classes and Objects

Classes and Objects   Introduction The Basics Properties Class Constants Autoloading Classes Constructors and Destructors Visibility Object Inheritance Scope Resolution Operator (::) Static Keyword Class Abstraction Object Interfaces Traits Anonymous classes Overloading Object Iteration Magic Methods Final Keyword Object Cloning Comparing Objects Type Hinting Late Static Bindings Objects and references Object Serialization OOP Changelog

PHP Control Structures

Control Structures   Introduction if else elseif/else if Alternative syntax for control structures while do-while for foreach break continue switch declare return require include require_once include_once goto

PHP Operators

Operators   Operator Precedence Arithmetic Operators Assignment Operators Bitwise Operators Comparison Operators Error Control Operators Execution Operators Incrementing/Decrementing Operators Logical Operators String Operators Array Operators Type Operators An operator is something that takes one or more values (or expressions, in programming jargon) and yields another value (so that the construction itself becomes an expression). Operators can be grouped according to the number of values they take. Unary operators take only one value, for example  !  (the  logical not operator ) or  ++  (the  increment operator ). Binary operators take two values, such as the familiar  arithmetical operators   +  (plus) and  -  (minus), and the majority of PHP operators fall into this category. Finally, there is a single  ternary operator ,  ? : , which takes three values; this is usually referred to simply as "t...

PHP Expressions

Expressions   Expressions are the most important building blocks of PHP. In PHP, almost anything you write is an expression. The simplest yet most accurate way to define an expression is "anything that has a value". The most basic forms of expressions are constants and variables. When you type " $a  = 5", you're assigning '5' into  $a . '5', obviously, has the value 5, or in other words '5' is an expression with the value of 5 (in this case, '5' is an integer constant). After this assignment, you'd expect  $a 's value to be 5 as well, so if you wrote  $b  =  $a , you'd expect it to behave just as if you wrote  $b  = 5. In other words,  $a  is an expression with the value of 5 as well. If everything works right, this is exactly what will happen. Slightly more complex examples for expressions are functions. For instance, consider the following function: function  foo  () {     return  5...

PHP Constants

Constants   Syntax Magic constants A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for  magic constants , which aren't actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase. The name of a constant follows the same rules as any label in PHP. A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thusly:  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* Tip See also the  Userland Naming Guide . Example #1 Valid and invalid constant names // Valid constant names define ( "FOO" ,      "something" ); define ( "FOO2" ,     "something else" ); define ( "FOO_BAR" ,  "something more" ); // Invalid constant...