Simple scripts in php for beginners

<?Php
echo "Hello World";
?>
<?Php
for($i=0;$i<20;$i++){
for($j=0;$j<$i;$j++){
echo '*';
}
echo '<br>';
}
?>
Demo

<?Php
echo "<form name=f1 method=post action=''>
<input type=text name=t1><input type=submit value='Submit'></form>";
@$t1=$_POST['t1']; // Collect the string as entered by user
if(strlen($t1) > 1 ){ // If the length of the string is more than 1
echo "Welcome $t1<br>
Your name in reverse : ".strrev($t1);
}
?>
Demo
<?Php
$string= "Welcome to plus2net.com";
echo $string."<br>";
echo "Length of the string : ".strlen($string);
?>
Demo
<?Php
$string= "welcome to plus2net.com";
echo $string."<br>";
echo "After changing : ".ucfirst($string);
?>
Demo
<?Php
$v1=5;// Change this number
for($i=1;$i<11;$i++){
echo "$v1 x $i = ".$v1*$i;
echo '<br>';
}
?>
Demo
<?Php
$v1=10;
$v2=30;
echo "Sum of two numbers $v1 + $v2 = ". ($v1 + $v2); ?>
Demo
<?Php
for($i=1;$i<=20;$i++){
if($i % 2 ==0){
echo $i;
echo '<br>'; // Line break
}
}
?>
Demo
<?Php
$v1=68; $v2=12;$v3=135;$v4=22;
echo "Four Numbers are : $v1,$v2,$v3,$v4 <br>";
echo " Highest Number is : ".max($v1,$v2,$v3,$v4);
?>
Demo
<?Php
echo date("m/d/y : H:i:s", time()); 
?>
Demo
<?Php
$m= date("m");
$de= date("d");
$y= date("Y");
for($i=0; $i<=20; $i++){
echo date('d-M-Y:D',mktime(0,0,0,$m,($de-$i),$y)); 
echo "<br>";
}
?>
Demo

More Basic scripts in PHP

Check the string or number is Palindrome or not in PHP Factorial of a number Sum of digits of a number Strong Number Armstrong number
Fibonacci Series
Introduction to PHP
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Gaurav

    16-07-2014

    Hi

    How yo print below using for loop logic

    1
    2 5
    3 6 8
    4 7 9 10
    subhpurohit

    28-06-2017

    please give details in programs

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer