Language Selection

English French German Italian Portuguese Spanish

PHP Leftovers/Programming

Filed under
  • 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.

More in Tux Machines

GNOME 40 Alpha Released

GNOME 40 is now available as the first step towards releasing this updated Linux desktop environment in March. GNOME 40 Alpha comes with a ton of changes -- many of which we have been outlining in various Phoronix articles over the past few months. Among the main highlights of GNOME 40 Read more

Kali Linux hands-on: A look at the installation options

Anyone involved in or even significantly interested in cybersecurity has probably heard of Kali Linux. Since its early days as BackTrack, it has been considered the standard in penetration testing and security analysis platforms. In my opinion, it also happens to be one of the best Debian GNU/Linux distributions available. It is based on Debian stable (currently 10/buster), but with a much more current Linux kernel (currently 5.9 in Kali, compared to 4.19 in Debian stable and 5.10 in Debian testing). Read more

Ubuntu Emailing With Thunderbird And Android's K-9

Continuing email beginner's guide, now we Ubuntu users who have Android can read our emails anywhere anytime in both devices. It's a wonderful experience. On computer we use Thunderbird, while on phone we use K-9, both are free software. This tutorial uses Disroot email account as example, thanks to its gratis IMAP feature. Now, let's go! Fortunately, Ubuntu users do not need to install anything anymore. But for Android users, you will install K-9 Email Client, it is available at free software center F-Droid. Read more

Write GIMP scripts to make image processing faster

Some time ago, I wanted to give a blackboard-style look to a typeset equation. I started playing around with the GNU Image Manipulation Program (GIMP) and was satisfied with the result. The problem was that I had to perform several actions on the image, I wanted to use this style again, and I did not want to repeat the steps for all the images. Besides, I was sure that I would forget them in no time. GIMP is a great open source image editor. Although I have been using it for years, I had never investigated its batch-processing abilities nor its Script-Fu menu. This was the perfect chance to explore them. Read more