PHP Leftovers/Programming

-
Use of glob() function in PHP
glob() function is a built-in PHP function that is used to search the specific files or folders based on the pattern. It returns the file and folder names in an array that matches the pattern. How this function can be used to search the particular files or folders is shown in this tutorial.
-
Use of hash functions in PHP
Data security is very important for any application. The unauthorized access of the data can damage the valuable data of the application. If the data can be secured by applying proper encryption, then unauthorized access of the data can be prevented. For example, the password of the new user requires to encrypt before storing in the database to prevent unauthorized access of the user easily. One way of encryption is to use the hash function. Many built-in hash functions exist in PHP to encrypt the data. It encrypts the data without changing its original meaning. Some commonly used hash functions of PHP are md5(), sha1(), and hash(). The uses of these functions are explained in this tutorial.
-
Use of getenv() function in PHP
Environment variables are used in PHP to set up the application and retrieve the different types of data dynamically from the server. The database credentials, API keys, etc., are visible to the code through the environment variable instead of using any configuration file. When any PHP script runs, then it will inherit all required environment variables from the server. There are two ways to read environment variables in PHP. One is getenv() function and another is $_ENV array. The uses of the getenv() function are shown in this tutorial.
-
Use of foreach loop in PHP – Linux Hint
Many types of loops are supported by PHP. foreach loop is one of them. This loop is mainly used to parse array and object variables. When the total number of array elements is undefined, then it is better to use a foreach loop than another loop. The number of iterations of this loop depends on the number of array elements or the number of properties of the object used in the loop for reading. How this loop can be used for reading array and object variables is shown in this tutorial.
-
Use of PHP Global Variable – Linux Hint
The variable is used to store any value temporarily in the script. Two types of variables are used in any programming language. These are local and global variables. The variables which are accessible anywhere in the script called global variables. That’s mean the value of the global variables can be accessed or modified inside and outside of the function. But if the name of any global variable is the same as any variable declared inside a function there are some ways to recognize the global variable inside the function. Two types of global variables are used in PHP. One is a user-defined global variable and another is a superglobal variable. Some useful superglobal variables are $_GLOBALS, $_SERVER, $_REQUEST, $_GET, $_POST, $_FILES, $_COOKIE and $_SESSION. How the user-defined global variable can be declared, assigned, and changed inside and outside the function have shown in this tutorial.
-
Use of Heredoc in PHP – Linux Hint
Heredoc is one of the ways to store or print a block of text in PHP. The data stored in the heredoc variable is more readable and error-free than other variables for using indentation and newline. How the heredoc content can be stored in a variable or printed has shown in this tutorial.
-
Retrieve the Full URL in PHP – Linux Hint
Two types of global variables can be used in PHP: the superglobal variable and the user-defined variable. $_SERVER is a superglobal array variable that is used to retrieve the full path of the current page. The protocol (HTTP or HTTPS) of the URL is also required to get the full URL of the page. If $_SERVER[‘HTTPS’] returns ‘on’, then HTTPS will be used with the URL address, otherwise, HTTP will be used. How the full URL address of the current page can be retrieved using the $_SERVER array has been explained in this tutorial.
-
- Login or register to post comments
Printer-friendly version
- 1959 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
Recent comments
3 hours 53 min ago
11 hours 3 min ago
11 hours 34 min ago
11 hours 42 min ago
18 hours 54 min ago
19 hours 10 min ago
19 hours 42 min ago
23 hours 33 min ago
1 day 13 hours ago
1 day 14 hours ago