Found 33676 Articles for Programming

PHP ftp://

Malhar Lathkar
Updated on 22-Sep-2020 10:40:15

396 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

PHP file://

Malhar Lathkar
Updated on 22-Sep-2020 10:39:17

340 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

PHP data://

Malhar Lathkar
Updated on 22-Sep-2020 10:37:59

239 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

PHP $http_response_header

Malhar Lathkar
Updated on 22-Sep-2020 10:33:27

643 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

Split String of Size N in Python

Arnab Chakraborty
Updated on 22-Sep-2020 10:56:36

1K+ Views

Suppose we have a string s and an integer n, we have to split the s into n-sized pieces.So, if the input is like s = "abcdefghijklmn", n = 4, then the output will be ['abcd', 'efgh', 'ijkl', 'mn']To solve this, we will follow these steps −i:= 0f:= a new listwhile i < size of s, doinsert s[from index i to i+n-1] at the end of fi := i + nreturn fLet us see the following implementation to get better understanding −Example Live Democlass Solution:    def solve(self, s, n):       i=0       f=[]       while(i

Add the slug field inside Django Model

Hafeezul Kareem
Updated on 21-Sep-2020 13:02:30

477 Views

In this tutorial, we are going to learn about the SlugField in Django.SlugFieldSlugField is a way to generate a URL using the data which we already have. You can generate URL using your title of the post or page. Let's see one detailed example.Let's say we have an article with name This is from Tutorialspoint with id = 5. Then we can have URL as www.tutorialspoint.com/posts/5/. It's difficult for the content writers to recognize the article with the previous URL. But, if you have a URL like www.tutorialspoint.com/this-isfrom-tutorialspoint, then it's easy for us to identify the piece. So, SlugField is ... Read More

PHP $_FILES

Malhar Lathkar
Updated on 21-Sep-2020 12:14:49

26K+ 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

PHP $_ENV

Malhar Lathkar
Updated on 21-Sep-2020 12:13:43

6K+ 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

PHP $argv

Malhar Lathkar
Updated on 21-Sep-2020 12:09:24

5K+ 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

PHP $argc

Malhar Lathkar
Updated on 21-Sep-2020 12:08:10

589 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

Advertisements