How-to articles, tricks, and solutions about PHP

PHP: Read Specific Line From File

In PHP, you can read a specific line from a file using the file() function, which reads the entire file into an array, with each line of the file as an element in the array.

PHP: Storing 'objects' inside the $_SESSION

In PHP, the $_SESSION superglobal is used to store data that needs to persist across multiple page requests.

PHP: Telegram Bot: Insert line break to text message

To insert a line break in a text message sent from a Telegram bot written in PHP, use the special characters "\n" in the message string.

php.ini & SMTP= - how do you pass username & password

To pass a username and password to the SMTP server in the php.ini file, you can use the following format:

PHP's file_exists() will not work for me?

The file_exists() function in PHP can be used to check if a file exists on the file system.

PHP/MySQL insert row then get 'id'

To insert a row into a MySQL database table and get the id of the inserted row in PHP, you can use the mysqli_insert_id() function.

php/mySQL on XAMPP: password for phpMyAdmin and mysql_connect different?

The password for accessing phpMyAdmin and the password for connecting to the MySQL server using the mysql_connect() function can be different.

PHP/regex: How to get the string value of HTML tag?

In PHP, you can use the preg_match() function to extract the string value of an HTML tag.

PHPExcel and Text Wrapping

PHPExcel is a library for working with Microsoft Excel files in PHP.

PHPExcel Column Loop

To loop through columns in PHPExcel, you can use the following code snippet as an example:

PHPMailer - SMTP ERROR: Password command failed when send mail from my server

This error message typically indicates that the SMTP server is unable to authenticate the provided login credentials for the email account being used to send the email.

phpmailer - The following SMTP Error: Data not accepted

The "SMTP Error: Data not accepted" is a common error message that can occur when using the PHPMailer library to send email messages.

phpmailer: Reply using only "Reply To" address

To send an email using PHPMailer and have the reply go only to the "Reply-To" address, you can set the "addReplyTo" method and pass in the email address you want the reply to go to.

phpMyAdmin allow remote users

phpMyAdmin is a web-based tool for managing MySQL and MariaDB databases.

phpMyAdmin Error: The mbstring extension is missing. Please check your PHP configuration

It looks like you are trying to use phpMyAdmin, but it is giving you an error message saying that the mbstring extension is missing.

phpMyAdmin mbstring error

It looks like you are encountering an error with the mbstring extension in PHP when using phpMyAdmin.

PHPUnit: assert two arrays are equal, but order of elements not important

You can use the assertEqualsCanonicalizing or assertEqualsIgnoringCase methods to compare two arrays and ignore the order of the elements.

Populate a Drop down box from a mySQL table in PHP

You can use the PHP MySQLi extension to connect to a MySQL database and retrieve the data from a table to populate a drop-down box.

Post Requests with cURL

cURL is applied for making requests with different protocols. A post request can send user collected data to a server. Find out how to do that accurately.

postgresql insert null value on query

To insert a NULL value into a PostgreSQL database table column using PHP, you can use the NULL keyword in your INSERT query.

posting hidden value

In PHP, you can post a hidden value by including it in a hidden input field within a HTML form.

Prevent nginx 504 Gateway timeout using PHP set_time_limit()

You can use the set_time_limit() function in PHP to increase the maximum execution time of a PHP script.

Print array to a file

To print an array to a file in PHP, you can use the file_put_contents() function, which writes a string to a file.

Proper Repository Pattern Design in PHP?

The Repository pattern in PHP is a design pattern that allows for the separation of the business logic of an application from the storage and retrieval of data.

Proper URL forming with a query string and an anchor hashtag

To form a proper URL with a query string and an anchor hashtag in PHP, you can use the http_build_query() function to create the query string and concatenate it to the base URL using the ?