How to Convert A String To Uppercase in PHP The PHP strtoupper() function is used to convert a string to uppercase. Try the below example to under the working of this function, which convert all alphabets of a string to uppercase. Example:
| <?php $str = 'Welcome to Tecadmin.net'; echo strtoupper($str); ?> |
Output: WELCOME TO TECADMIN.NET
Read More How to Combine Two Strings in PHP The PHP programming language uses dot (.) operator to create singe string by combining two strings. This operator is specifically designed for strings. You can use this operation in multiple ways. Example 1:
| <?php // A sample php script to demonstrate contamination // of two strings in PHP $str1 = "Welcome"; $str2 = "Tecadmin!"; $result = $str1 . " " . $str2; echo $result; // Output: Welcome Tecadmin! ?> |
You can also concatenate one string and other string variable. For example:
| <?php $str1 = "Welcome"; $result = $str1 . " Tecadmin!"; echo $result; // Output: Welcome Tecadmin! ?> |
You can also concatenate with assignment operator (‘.=’), which appends the argument on the right side to the argument on the left side. For example:
| <?php $str1 = "Welcome"; $str1 .= " Tecadmin!"; echo $str1; // Output: Welcome Tecadmin! ?> |
Read More How to Get the Current Year using PHP PHP date() function is used for getting date. You can customize the output by passing the values to the function. For example, to get the current year pass “Y” to the function. This will show you the current date only. Use below sample PHP program to print current year.
| <?php // PHP program to get the current year echo "Current Year is :"; $year = date("Y"); echo $year; ?> |
This is also useful for the printing the copyright statement with the current year at the footer of your website. For example add below state to your php script footer file.
| <p> Copyright © <?php echo date("Y"); ?> example.com. All Rights Reserved. </p> |
Read More List of FAQ’s for PHP programming language.
Read More Run PHP CLI Application with Docker Docker provides official images to run PHP script on command line. These are helpful to run script on shell, scheduled jobs with php script like cron jobs. This tutorial will help you to run a sample php script on CLI using Docker containers. Run PHP CLI on Docker The CLI scripts run on a terminal, these scripts are helpful to background jobs, scheduled jobs with the crontab. The below example, will run a sample php script with CLI on Docker. Create PHP Script –…
Read More Run PHP Web Application with Docker You can run any PHP application on using web server or command line using Docker containers. This tutorial will help you to run a PHP script over command line with a Docker container. Also, you will find the instructions to run a PHP script over Apache/Nginx web server with Docker. Docker PHP Example with Apache Create PHP Script – First, create a sample PHP script to run on web server under the Docker container. Edit index.php in your favorite text editor. nano index.php Add…
Read More