Core php Programming Examples
core php programming examples to swap two numbers
<?php
$a=20;
$b=10;
echo "a="." ".$a." "."b="." ".$b;
$temp=$a;
$a=$b;
$b=$temp;
echo "<br>";
echo "after swapping A is"." ".$a." "."and b is"." ".$b ;
?>
$a=20;
$b=10;
echo "a="." ".$a." "."b="." ".$b;
$temp=$a;
$a=$b;
$b=$temp;
echo "<br>";
echo "after swapping A is"." ".$a." "."and b is"." ".$b ;
?>
core php programming examples to Fahrenheit temperature into Celsius
<?php
$f=55 ;
$c=($f-32)*5/9;
echo $c;
?>
$f=55 ;
$c=($f-32)*5/9;
echo $c;
?>
Program to print even numbers between 1 and 20 in php
<?php
for($i=1;$i<=20;$i++)
{
if($i%2!=0)
{
echo $i." ";
}
}
for($i=1;$i<=20;$i++)
{
if($i%2!=0)
{
echo $i." ";
}
}
Program in php to print first 10 natural numbers
<?php
for($i=1;$i<11;$i++)
{
echo $i ." ";
}
?>
for($i=1;$i<11;$i++)
{
echo $i ." ";
}
?>
Program in php to generate pyramid
<?php
$i=1;
for($i=1; $i<=3; $i++)
{
for($j=1; $j<=$i; $j++)
{
echo '*';
}
echo '<br/>';
}
?>
$i=1;
for($i=1; $i<=3; $i++)
{
for($j=1; $j<=$i; $j++)
{
echo '*';
}
echo '<br/>';
}
?>