<?php
$year=2017; if($year%4==0) { $leap="It is a leap year"; } else { $leap="It is not a leap year"; } ?>
Friday, 28 July 2017
Program to find year is LEAP year or not.
Write a program to print Fibonacci series
Write a program to print Fibonacci series
<?php
$fibo=array(0,1);
$num=4;for($i=2;$i<=$num-1;$i++){$fibo[$i]=$fibo[$i-1]+$fibo[$i-2];}?>
To check whether a number is Prime or not.
<?php
?>
$check=0;
$num=$_POST['number'];
for($i=2;$i<=($num/2);$i++)
{
if($num%$i==0)
{
$check++;
if($check==1)
{
break;
}
}
}
?>
Write a program to print Reverse in php
<?php
$rev=0;
$num=4;
while($num>=1)
{
$re=$num%10;
$rev=$rev*10+$re;
$num=$num/10;
}
?>
$rev=0;
$num=4;
while($num>=1)
{
$re=$num%10;
$rev=$rev*10+$re;
$num=$num/10;
}
?>
Write a program to find whether a number is Armstrong or not in php.
<?php
if(isset($_POST['number']) && $_POST['number']!='')
{
$number = $_POST[ 'number' ]; // get the number entered by user
$temp = $number;
$sum = 0;
while($temp != 0 )
{
$remainder = $temp % 10; //find reminder
$sum = $sum + ( $remainder * $remainder * $remainder );
$temp = $temp / 10;
}
if( $number == $sum )
{
echo "$number is an Armstrong Number";
}else
{
echo "$number is not an Armstrong Number";
}
}
?>
Write a program in PHP to print Fibonacci series . 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
<?PHP
$first = 0;
$second = 1;
echo $first.' ,';
echo $second.' ,';
for($limit=0;$limit<10;$limit++)
{
$third = $first+$second;
echo $third.' ,';;
$first = $second;
$second = $third;
}
?>
$first = 0;
$second = 1;
echo $first.' ,';
echo $second.' ,';
for($limit=0;$limit<10;$limit++)
{
$third = $first+$second;
echo $third.' ,';;
$first = $second;
$second = $third;
}
?>
Write a program to print Factorial number in php.
<?php
$num = 4;
$factorial = 1;
for ($x=$num; $x>=1; $x--)
{
$factorial = $factorial * $x;
}
echo "Factorial of $num is $factorial";
?>
Output
Factorial of 4 is 24
$num = 4;
$factorial = 1;
for ($x=$num; $x>=1; $x--)
{
$factorial = $factorial * $x;
}
echo "Factorial of $num is $factorial";
?>
Output
Factorial of 4 is 24
Friday, 21 July 2017
Display latest comments in wordpress template.
Display latest comments for each post in WordPress
<?php
$commentArr = array_reverse(get_approved_comments($wp_query->post->ID));
$count = 1; // number of comments
if ($commentArr) { ?>
<h3><?php commentsNum('0 comment', '1 comment', '% comments'); ?></h3>
<ul>
<?php foreach ($commentArr as $comment) {
if ($count++ <= 2) { ?>
<li><?php comment_author_link(); ?>: <?php comment_excerpt(); ?></li>
<?php }
} ?>
</ul>
<?php } else {
echo '<p>No Comments..</p>';
} ?>
<?php
$commentArr = array_reverse(get_approved_comments($wp_query->post->ID));
$count = 1; // number of comments
if ($commentArr) { ?>
<h3><?php commentsNum('0 comment', '1 comment', '% comments'); ?></h3>
<ul>
<?php foreach ($commentArr as $comment) {
if ($count++ <= 2) { ?>
<li><?php comment_author_link(); ?>: <?php comment_excerpt(); ?></li>
<?php }
} ?>
</ul>
<?php } else {
echo '<p>No Comments..</p>';
} ?>
Thursday, 20 July 2017
How to add facebook fun page in Blog and page.
Click "Add Widget" to post a badge on your Blogger site that links to your Facebook account.
Step 2: Place this code wherever you want the plugin to appear on your page.
<iframe src="https://www.facebook.com/plugins/follow.php?href=https%3A%2F%2Fwww.facebook.com%2Fmanjeetkashyapsaharanpur&width=250&height=80&layout=standard&size=large&show_faces=true&appId" width="250" height="80" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
Change facebook page name.
Step 2: Place this code wherever you want the plugin to appear on your page.
<iframe src="https://www.facebook.com/plugins/follow.php?href=https%3A%2F%2Fwww.facebook.com%2Fmanjeetkashyapsaharanpur&width=250&height=80&layout=standard&size=large&show_faces=true&appId" width="250" height="80" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
Change facebook page name.
Monday, 17 July 2017
How to hide admin bar in wordpress frontend.
If you would rather remove the toolbar with code, just drop the following snippet into your functions.php file:
add_filter('show_admin_bar', '__return_false');
add_filter('show_admin_bar', '__return_false');
Subscribe to:
Posts (Atom)