How-to articles, tricks, and solutions about PHP
If cURL is returning a HTTP code of 0, it usually indicates that cURL was unable to communicate with the server.
To call a PHP function using an onclick event, you will need to use a little bit of JavaScript.
To truncate a string in PHP to the word closest to a certain number of characters, you can use the following code:
The $_SERVER['HTTP_REFERER'] variable is a server-side variable that contains the URL of the page that linked to the current page.
To open a form submission in a new tab, you can use the target attribute of the form element and set it to _blank.
To enable mod_rewrite on a PHP server, you will need to make sure that the Apache mod_rewrite module is installed and enabled.
You can use the global keyword to access a global variable inside a class.
The Elvis operator, represented by a question mark followed by a colon (?:), is a ternary operator in PHP that is used to simplify expressions that return a value based on a condition.
To insert data into a database using PDO and prepared statements, you can use the following steps:
To add data dynamically to an array in PHP, you can use the $array[] = $value syntax.
To install Laravel's Artisan, you will need to install the Laravel framework on your machine first.
To insert a new record into a MySQL table that has an auto-increment primary key, you can use the INSERT statement with a list of comma-separated values.
In PHP, both 'AND' and '&&' are logical operators that are used to test if two statements are true.
To print all properties of an object in PHP, you can use the get_object_vars function, which returns an associative array of an object's properties.
There could be a few reasons why the imagecreatefromjpeg function and similar functions are not working in your PHP script.
To format a float to have 2 decimal places in PHP, you can use the number_format() function.
Upgrading PHP on CentOS 6.5 can be a bit tricky, since CentOS 6.5 uses an older version of PHP.
Long-polling, WebSockets, Server-Sent Events (SSE), and Comet are all techniques used to enable real-time communication between a client (usually a web browser) and a server.
To display a string that contains HTML in a Twig template, you can use the raw filter.
This error usually occurs when you are trying to use the json_decode() function, which is used to decode a JSON string into a PHP variable, but the function is not available.
You can use the following regular expression to extract the YouTube video ID from a URL:
To check if a URL parameter exists in PHP, you can use the isset function.
To fix the "set SameSite cookie to none" warning in PHP, you will need to specify the SameSite attribute when you set the cookie.
To get the ID of the last inserted row, you can use the LAST_INSERT_ID() function.
In order to include new lines in the body of an email sent with PHP, you will need to use the proper new line characters.