How-to articles, tricks, and solutions about PHP

How to Use the mhash_keygen_s2k() Function in PHP

The aim of this snippet is to represent to you the PHP mhash_keygen_s2k() function. Read on and check out the example for better understanding.

How to use the php that brew installed?

To use the PHP that Homebrew installed, you will first need to make sure that it is in your system's PATH.

How to Use the Scope Resolution Operator in PHP

In this snippet, you will find comprehensive information about the scope resolution. Explore the ways of using the scope resolution operator in PHP.

How to Use the StartsWith() and EndsWith() Functions in PHP

Sometimes, the work with PHP requires to check whether a string starts or ends with a particular string. Learn how to do it with the help of our tutorial.

How to use wget in php?

You can use the exec function in PHP to execute the wget command.

How to Validate an Email with PHP

This tutorial explains how to validate an email using the PHP arsenal. Check out the examples of how to do that with the help of a PHP function and regex.

How to validate array in Laravel?

In Laravel, you can use the validate method on the Validator facade to validate an array of form data.

How to validate Google reCAPTCHA v3 on server side?

To validate a Google reCAPTCHA v3 on the server side using PHP, you will need to do the following steps:

How to Validate on Max File Size in Laravel?

To validate a file size in Laravel, you can use the size rule in your request validation.

How to Validate URL with PHP

In this snippet, we provide guidelines on one of the most common issues in PHP. Here, we show the most straightforward way on how to validate URL with PHP.

How to work on UAC when installing XAMPP

To work with User Account Control (UAC) when installing XAMPP, you can try the following steps:

How to write a link like <a href="#id"> which link to the same page in PHP?

In PHP, you can use the echo function to output an HTML <a> tag with a "#id" value for the href attribute, which will link to the same page.

How to write own DD() function same as laravel?

To create your own version of the Laravel DD() function, you can create a new function in your codebase and have it take in any number of arguments.

How validate unique email out of the user that is updating it in Laravel?

In Laravel, you can use the unique validation rule to validate that an email address is unique when a user is updating their account.

Htaccess: add/remove trailing slash from URL

To add or remove a trailing slash from the end of a URL using an .htaccess file, you can use mod_rewrite to rewrite the URL.

HTML Upload MAX_FILE_SIZE does not appear to work

In PHP, you can use the $_FILES array to check the size of an uploaded file.

HTML/PHP - Form - Input as array

To create an HTML form that submits an array as a form parameter, you can use the name attribute of the input element and give it a value in the form of an array.

HTTP authentication logout via PHP

To log out a user from HTTP authentication using PHP, you can use the header function to send a "WWW-Authenticate" header with a value of "Basic realm=realmName" and a 401 status code.

HTTP requests with file_get_contents, getting the response code

To make an HTTP request using the file_get_contents function in PHP and retrieve the response code, you can use the following code snippet:

if block inside echo statement?

It is not possible to include an "if" block inside an "echo" statement in PHP.

If else embedding inside html

There are a few different ways you can embed PHP code inside HTML.

Ignore case sensitivity when comparing strings in PHP

In PHP, you can use the strcasecmp() function to compare two strings and ignore case sensitivity.

imagecreatefromjpeg and similar functions are not working in PHP

There could be a few reasons why the imagecreatefromjpeg function and similar functions are not working in your PHP script.

In Laravel is there a way to add values to a request array?

Yes, you can add values to a request array in Laravel by using the merge method on the request object.

In PHP with PDO, how to check the final SQL parametrized query?

In PHP with PDO, you can use the debugDumpParams() method on a prepared statement object to view the final SQL parametrized query.