PHP Programs

Here, at phptpoint we begin from the scratch where we can lead you on the practice of these languages.

This is a free and online site where the students who want to build a career in the same profession, can be trained about the working of the PHP.

The following are the most important PHP programs that are frequently asked in interviews. These programs cover PHP fundamentals, PHP control statements, PHP arrays, PHP strings, PHP oops, PHP file handling, and so on.

Even Odd Program

A program to check 1233456 is odd or even is shown.

Example:

  1. <?php
  2. $number=1233456;
  3. if($number%2==0)
  4. {
  5. echo “$number is Even Number”;
  6. }
  7. else
  8. {
  9. echo “$number is Odd Number”;
  10. }
  11. ?>

Output:

Alphabet Triangle using PHP method

Some different alphabet triangle patterns using range() function in PHP are shown below.

  1. <?php
  2. $alpha = range(‘A’, ‘Z’);
  3. for($i=0; $i<5; $i++){
  4. for($j=5; $j>$i; $j — ){
  5. echo $alpha[$i];
  6. }
  7. echo “<br>”;
  8. }
  9. ?>

Output:

Star Triangle

The star triangle in PHP is made using for and foreach loop. There are a lot of star patterns. We’ll show some of them here.

Pattern 1

  1. <?php
  2. for($i=0;$i<=5;$i++){
  3. for($j=5-$i;$j>=1;$j — ){
  4. echo “* “;
  5. }
  6. echo “<br>”;
  7. }
  8. ?>

Output:

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

UNDERSTANDING THE BASICS OF FLEXBOX

TrumpCL — A Proposed Computer Language Inspired by the Trump Presidency

3 simple steps to play YouTube in the background

Brave browser’s logo

Arth Task 11.1

Brief Introduction to Spark SQL Engine

Easily Terraforming an EthSigner with an Azure Key Vault HSM Based Key

Getting Started with Kubernetes | A Brief History of Cloud-native Technologies

Optimizing your Images for the Web using JPEG, WEBP and AVIF in 2021 (featuring ImageMagick)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
sanjeev kumar

sanjeev kumar

More from Medium

Log activities in Laravel

Laravel Console: Options for your Seeders

Deep dive into Laravel Pagination — PHP IteratorAggregate

Laravel 8