Posts by Devsheet

Read all articles posted by Devsheet programmers and content writers.

PHP Script to download image from remote url

This PHP script allows you to download an image from a remote URL. This can be useful when you want to download an image from a website that does not allow direct linking to images.

Uppercase first character of each word of a String in PHP

If you need to uppercase the first character of each word in a string in PHP, you can use the ucwords() function. This function takes a string as an argument and returns a new string with the first character of each word in the original string capitalized.

Uppercase first character of a String in PHP

If you need to uppercase the first character of a string in PHP, you can use the ucfirst() function. This function takes a string as an argument and returns a new string with the first character uppercased.

Lowercase first character of a String in PHP

If you need to lowercase the first character of a string in PHP, you can use the lcfirst() function. This function takes a string as an argument and returns the string with the first character converted to lowercase.

Convert string to uppercase in PHP

If you need to convert a string to uppercase in PHP, you can use the strtoupper() function. This function takes a string as an argument and returns a string with all uppercase letters.

Loop through Array of Objects in PHP

In PHP, there are a few different ways to loop through an array of objects. The most common way is to use a foreach loop. This type of loop will iterate through each object in the array and perform the specified actions.

How to Use PHP to Get the Client IP Address

When PHP is used to get the client IP address, it is first important to understand what an IP address is. An IP address is a unique number that is assigned to each device that is connected to the internet. This number is used to identify the device and allow it to communicate with other devices on the network.

Get random value from an array in PHP

When working with PHP, sometimes you need to get a random value from an array. This can be easily accomplished with the array_rand() function. We will show multiple methods in this post that can be used to get the random item from an array.

Assign a Javascript variable to PHP variable

When working with PHP and JavaScript together, there are times when you need to pass values from JavaScript to PHP. This can be done by assigning a JavaScript variable to a PHP variable. In this post, We will explain different methods to do that.

Check if string contains a substring using PHP

If you're working with strings in PHP, it's often necessary to check if a string contains a particular substring. For instance, you might want to check if a string contains a URL or an email address.

PHP program to get the values of checkboxes on Form Submit

When creating a form in PHP we used multiple input controls. If you are using checkbox input in your form and want to get the values of selected checkboxes on the Form Submit then you can the code examples explained in this post.

Convert String to an Integer in PHP

We can use the int keyword to convert a String value to an integer type value in PHP. Check the code examples explained in this post.

PHP program to find the number of days between two dates

Trying to get the number of days between two dates? You can use the methods explained in this post.

Print or echo new line using PHP

We can use PHP_EOL to print or echo a new line in PHP. We can also use \n or \r\n to echo the new line in PHP.

Display errors if not shown in PHP script

If you are unable to see the error that occurred in a PHP script then you can use the below code to show errors.

Validate IP address using filter_var() method PHP

You can use filter_var() with FILTER_VALIDATE_IP to validate an IP address in PHP. Below is the code example for that.

Validate a number using filter_var() method in PHP

If you want to validate a number in PHP you can use the filter_var() method and pass value and FILTER_VALIDATE_INT as parameters.

Send POST request without using curl using PHP 5+

If you are using a PHP version higher than 5, then you can easily send a post request without using curl. The code to send post requests in PHP is as below.

String interpolation and formation in PHP

We can easily format strings with variables in PHP. In the code snippet, we are formatting our string using variable name and using curly brackets.

Join or concatenate two or multiple strings in PHP

You can use the dot(.) operator of PHP to join or concatenate multiple strings into one.

PHP program to generate a token that is cryptographically secured

You can use PHP openssl_random_pseudo_bytes() or random_bytes() methods to generate random bytes of a fixed number and then convert them to readable format using the bin2hex() method.

Check if a folder already created using PHP

You can use this code to check whether a folder or directory already exists or not. We are using a PHP script to check that.

Convert Mysql date to Google sitemap date format PHP

Convert your MySql format date to the date that can be readable to Google sitemaps API using PHP

Capitalize text PHP

ucfirst() method can be used to capitalize text in PHP

Convert String date to DATE MONTH-NAME YEAR format php

To convert a string to a formatted date you can use the date() method in PHP

Create constructor in PHP OOP

You can create a constructor of a class using __construct() function

Get first n words from a paragraph in PHP

You can use this code to get first n words from a paragraph or sentence

Get current directory in PHP

You can get the current directory in PHP using this code

Firebase push notification curl request in PHP

This is a working example of a firebase push notification in PHP that uses CURL to send a request for a firebase cloud messaging service to send a push notification.

Get values array by key name using array_column() PHP

You can get an array of values by key name from an associative array using the array_column() function PHP

Define array PHP

In this code example, we are describing how you can define an array in PHP.

Check if value exist in array using in_array() PHP

You can check if a value exists in the given array or not using PHP inbuilt function in_array().

Send mail in PHP using PHPMailer

Code and description to send mail in PHP using the PHPMailer package.

Add item to array PHP

Adding items to an array in PHP is a relatively simple task that can be accomplished in a number of different ways. The most common way to add an item to an array is by using the array_push() function, which adds an item to the end of an array. Other ways to add items to an array include using the array_unshift() function, which adds an item to the beginning of an array.

Loading more...
Search all posts...