- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1046 Articles for PHP
288 Views
IntroductionThe glob:// stream wrapper is available in all PHP versions after 5.3.0. It finds pathnames that match given pattern. Similar purpose is fulfilled by PHP's filesystem function glob() which follows libc glob() rules.ParametersSpecial characters* − Matches zero or more characters.? − Matches exactly one character (any character).[...] − Matches one character from a group of characters. If the first character is !, matches any character not in the group.\ − Escapes the following character, except when the GLOB_NOESCAPE flag is used.Valid flagsGLOB_MARK − Adds a slash (a backslash on Windows) to each directory returnedGLOB_NOSORT − Return files as they appear ... Read More
248 Views
IntroductionBoth ftp:// and ftps:// wrappers allow read access to URLs with ftp (and ftps) protocol. New file can also be created using these wrappers. If passive mode ftp support is not possible in the server, connection will fail.Simultaneous read-write operations are not permitted with streams using ftp protocol. If it is required to overwrite existing file, it may be done by specifying overwrite option in context options.The php.ini file has from setting which specifies email ID to be used for unauthenticated FTP connection.If it is set, it is used as anonymous FTP password. It is also possible to have ftp access ... Read More
244 Views
IntroductionVarious URL-style protocols can be used with filesystem functions with the help of corresponding built-in wrappers avalable in PHP. The stream_wrapper_register() function is also there to define custom wrapper.Default wrapper in PHP is file:// and it represents local filesystem. If no other protocol is explicitly used, PHP parser treats it as filesystem wrapper. The filename argument to be given to filesystem functions fopen(), file_get_contents() etc uses file:// protocol by default.When file name doesn't begin with forward or backward slash, or drive letter in Windows, its path is taken as relative to current directory. However, in fopen() and file_get_contents() functions, file name ... Read More
166 Views
IntroductionThe data URI scheme has been defined in RFC 2397, published in 1998. It provides a mechanism to include in-line data in web page as if it is an external resource. PHP provides data:// wrapper for data URI representation. The data URI is represented as per following syntaxdata:// syntaxdata:[media type][;base64], dataparametersmedia type − Default is text/plainoptional base64 extension base64, separated from the preceding part by a semicolon, ndicating that the data content is binary data, encoded using the Base64 scheme for binary-to-text encoding.The data, separated from the preceding part by a comma (, ). The data is a sequence of zero ... Read More
491 Views
IntroductionThe superglobal $http_response_header array is populated by HTTP response headers as is the case with get_headers() functions. This array is created in local space of PHP$http_response_headerExampleOutputBrowser will display result similar to following0=>HTTP/1.1 302 Found 1=>Date: Tue, 08 Sep 2020 14:49:24 GMT 2=>Server: Apache/2.4.41 (Win64) OpenSSL/1.0.2s PHP/7.1.32 3=>X-Powered-By: PHP/7.1.32 4=>Location: http://localhost/dashboard/ 5=>Content-Length: 0 6=>Connection: close 7=>Content-Type: text/html; charset=UTF-8 8=>HTTP/1.1 200 OK 9=>Date: Tue, 08 Sep 2020 14:49:24 GMT 10=>Server: Apache/2.4.41 (Win64) OpenSSL/1.0.2s PHP/7.1.32 11=>Last-Modified: Mon, 02 Sep 2019 15:45:31 GMT 12=>ETag: "1d99-59193dc9c3cc0" 13=>Accept-Ranges: bytes 14=>Content-Length: 7577 15=>Connection: close 16=>Content-Type: text/html
23K+ Views
IntroductionThe global predefined variable $_FILES is an associative array containing items uploaded via HTTP POST method. Uploading a file requires HTTP POST method form with enctype attribute set to multipart/form-data.$HTTP_POST_FILES also contains the same information, but is not a superglobal, and now been deprecatedThe _FILES array contains following properties −$_FILES['file']['name'] - The original name of the file to be uploaded.$_FILES['file']['type'] - The mime type of the file.$_FILES['file']['size'] - The size, in bytes, of the uploaded file.$_FILES['file']['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.$_FILES['file']['error'] - The error code associated with this file upload.Following ... Read More
5K+ Views
Introduction$_ENV is another superglobal associative array in PHP. It stores environment variables available to current script. $HTTP_ENV_VARS also contains the same information, but is not a superglobal, and now been deprecated.Environment variables are imported into global namespace. Most of these variables are provided by the shell under which PHP parser is running. Hence, list of environment variables may be different on different platforms.This array also includes CGI variables in case whether PHP is running as a server module orCGI processor.PHP library has getenv()function to retrieve list of all environment variables or value of a specific environment variablegetenvFollowing script displays values ... Read More
3K+ Views
IntroductionWhen a PHP script is run from command line, $argv superglobal array contains arguments passed to it. First element in array $argv[0] is always the name of script. This variable is not available if register_argc_argv directive in php.ini is disabled.$argvFollowing script is executed from command line.Example Live DemoOutputarray(1) { [0]=> string(8) "main.php" }In another example as follows, addition of command line arguments is performedExampleOutputC:\xampp\php>php test1.php 10 20 addition = 30
397 Views
IntroductionThis superglobal variable is available when a PHP script is run from command line (and not when executed from HTTP server's document root). It is an integer that corresponds to number of command line arguments passed to current script. As script's filename has to be entered in command line, minimumn value of $argc is 1. This variable is not available if register_argc_argv directive in php.ini is disabled.$argcFollowing script is expected to be run from command line with 3 arguments including name of scriptExample Live DemoOutputThis script is run with invalid number of argumentsC:\xampp\php>php test1.php 1 2 3 invalid number of argumentsThis script ... Read More
321 Views
IntroductionWith Weak references, it is possible to retain a reference to an object which does not prevent the object from being destroyed. Implementing cache like structures can be done by Weak reference.A weak reference is similar to a normal reference, except that it doesn’t prevent the garbage collector from collecting the object. If strong references to that object are not found, it will be immediately removed frommemory. This way it is possible to implement most of the benefits of a cache, with no memory issues.WeakReference class has been introduced in PHP 7.4. Before this version, same effect used to be ... Read More