How-to articles, tricks, and solutions about PHP

How to Replace a Word Inside a PHP String

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.

How to resolve ambiguous column names when retrieving results?

When retrieving results in PHP and encountering ambiguous column names, you can use table aliases to specify which table the column belongs to.

How to Resolve the Fatal error: Maximum Execution time of 30 seconds exceeded in PHP

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.

How to Return JSON from a PHP Script

This short tutorial will represent to you the most effective way of returning JSON from a PHP script.

How to run a PHP function from an HTML form?

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.

How to run my php file from mac terminal?

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.

How to search text using php if ($text contains "World")

You can use the strpos() function in PHP to search for a specific string within another string.

How to select year and month from the created_at attributes of database table in laravel 5.1?

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.

How to send a GET request from PHP?

To send a GET request from PHP, you can use the file_get_contents function or the cURL extension.

How to Send a PHP Email via SMTP with the PEAR

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.

How to Send a Post Request with PHP

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.

How to Send Email Attachments via PHP

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.

How to Send Email via PHP

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.

How to send Emoji with Telegram Bot API?

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.

How to send HTTPS posts using php

To send an HTTPS POST request using PHP, you can use the curl extension.

How to separate DATE and TIME from DATETIME in MySQL?

You can use the DATE() and TIME() functions to extract the date and time parts of a DATETIME value in MySQL.

How to Separate Odd and Even Elements from an Array Without Using a Loop in PHP

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.

How to set a class attribute to a Symfony2 form input

In Symfony2, you can set the class attribute of a form input by using the "attr" option in the form field configuration.

How to set and get Cookie in laravel

To set a cookie in Laravel, you can use the Cookie facade.

How to set for specific directory open_basedir

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.

How to Set HTTP Header to UTF-8 in PHP

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.

How to set php executable path vscode inside docker container?

To set the php.validate.executablePath in Visual Studio Code (VS Code) when running PHP inside a Docker container, you can follow these steps:

How to set upload_max_filesize in .htaccess?

To set the upload_max_filesize directive in an .htaccess file, you can use the following code:

How to Sort a Multidimensional Array by Value

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.

How to Sort an Array of Associative Arrays by Value of a Given Key in PHP

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.