Friday 28 July 2017

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;
                 }

?>

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.'&nbsp;,';
   echo $second.'&nbsp;,';
  
  for($limit=0;$limit<10;$limit++)
   {
     $third = $first+$second;
     echo $third.'&nbsp;,';;
     $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

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>';
} ?>

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.

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');

What is Practice in technical language.

When I'm saying "Practice", what does it mean? I would say:

    Practice is a habit.

    Practice is a routine.

    Practice does not need to remember.

    Practice comes by practicing.

    Practice needs dedication and commitment.