How-to articles, tricks, and solutions about PHP
Sometimes, it is necessary to replace a given word inside a string in PHP. Here, we will consider three helpful functions that help to carry out the task.
When retrieving results in PHP and encountering ambiguous column names, you can use table aliases to specify which table the column belongs to.
In this tutorial, we will show you handy solutions to implement once you encounter the fatal error: maximum execution time of 30 seconds exceeded in PHP.
This short tutorial will represent to you the most effective way of returning JSON from a PHP script.
To run a PHP function from an HTML form, you will need to create an HTML form with the desired inputs, such as text fields and submit buttons.
To run a PHP file from the Mac terminal, you will need to have a web server installed, such as Apache, and PHP should be configured correctly with the server.
You can use the strpos() function in PHP to search for a specific string within another string.
In Laravel 5.1, you can use the selectRaw method to select the year and month from the created_at attribute of a database table.
To send a GET request from PHP, you can use the file_get_contents function or the cURL extension.
In this short tutorial, we are going to show you how to use the PEAR option to send emails via SMTP accurately. Just follow the steps below.
In this snippet, we will share with you the most flexible and powerful ways of sending post requests with the help of PHP. Just check out the examples.
While sending a mail, it is often necessary to send attachments, too. In this snippet, we will show you how to send attachments with PHP mail easily.
PHP mail is a built in PHP function that is used for sending emails from PHP scripts. Check out our snippet to learn how to send email via PHP accurately.
To send an emoji using the Telegram Bot API in PHP, you can use the sendMessage method and include the emoji in the text of the message.
To send an HTTPS POST request using PHP, you can use the curl extension.
You can use the DATE() and TIME() functions to extract the date and time parts of a DATETIME value in MySQL.
Here, we provide a snippet, explaining how to separate odd and even elements from an array without using a loop in PHP. Read on and check out the examples.
In Symfony2, you can set the class attribute of a form input by using the "attr" option in the form field configuration.
To set a cookie in Laravel, you can use the Cookie facade.
You can set the open_basedir configuration option in the PHP configuration file (php.ini) to specify a specific directory for the open_basedir setting.
If you want to learn how to set the HTTP header to UTF-8 in PHP, then read this snippet, examine and run the examples, that are demonstrated in it.
To set the php.validate.executablePath in Visual Studio Code (VS Code) when running PHP inside a Docker container, you can follow these steps:
To set the upload_max_filesize directive in an .htaccess file, you can use the following code:
In this short tutorial, you will learn the most efficient ways to easily sort a multidimensional array by value using PHP. Just follow the steps below.
If you want to learn how to sort an array of associative arrays by value of a given key in PHP, then read our tutorial. Here, you can find handy solutions.