• Wordpress

    WordPress custom plugin development sample

    How to write plugin name in custom coding.

    Let us consider , we are coding a plugin to show students rank in web page . lets name the plugin rankboard plugin.

    1. First create a folder name rankboard in wp-content / plugins folder.

    2) create a page named rankboard.php. *** you can create with other name too different from folder name .

    3. write the name of plugin (declare the plugin name) in rankboard.php . like

    <?php
    /**

    *Plugin Name: Golflboard
    */

    How to add menu link of plugin to show feature and functionality in dashboard ?

    to add menu link on admin / dahboard to show plugin functionality write ..

    add_action(‘admin_menu’, ‘studentrank_admin’);

    here add_ action (”admin_menu”) creates a menu link on dashboard .

  • laravel,  php

    Laravel install in windows

    By Laravel Installer method

    • Install composer https://getcomposer.org/download/
    • In command Line write composer global require “laravel/installer”
    • Now go to path c:/wamp/www in cmd
    • now write further C:/wamp/www laravel new projectname

    By composer Installer method

    • Install composer https://getcomposer.org/download/
    • Now go to path c:/wamp/www in cmd
    • now write further composer create-project –prefer-dist laravel/laravel projectname

    thus the laravel file is installed for development.

  • javascript,  php

    Octal to Binary Number System

    Octal number has base 8    from digit 0 – 7  written as  (324)8

    Binary    Decimal

    1. 000          0
    2. 001          1
    3. 010          2
    4. 011          3
    5. 100          4
    6. 101          5
    7. 110          6
    8. 111          7

    Convert Octal to Binary

    1. (116)   ——-    (  001  001  110  ) 
      SO BINARY number for octal 116 is 1001110  just by putting 3 bit value for each digit in octal.
    2. (574.321)   ——-    ( 101 111 100.011 010 001 ) 
      SO BINARY number for octal 574.321 is101 111 100.011 010 001  just by putting 3 bit value for each digit in octal.

    Convert Octal to Decimal

    1. (116)=  1×8+   1×8+6×80   = 64+8+6  = (78)10  

    Convert Decimal to octal

    1. (70)10    =   8  | 70 |  6
      8  |   8 |  0
      1        there for the octal number of 70 base 10  is 106 base 8
  • php

    $_SERVER Use In Generating Dynamic URL and header function to redirect PHP

     $_SERVER is an array containing information lke header, url path. Entries are generated by web servers. It can help.

    • making dymamic redirection header location value.
    • make dynamic web links as per use
    • can provide you value from url dynamically to operate with variables as per requirement.

    $host = $_SERVER[‘HTTP_HOST’]; // gives host link/  domain name. as per applied
    $uri = rtrim(dirname($_SERVER[‘PHP_SELF’]), ‘/\\’); // directory name  in between weblink.
    $urib = $_SERVER[‘PHP_SELF’]; // all values after domain name so in above dirname function is used to avoid ful value of url link 
    $extra = ‘page.php’;

    header(“Location: http://$host$uri/$extra”);

    // 1) a way of dynamic generation of  link by contaction $host value, $ uri value 

    2)  to redirect with header function

  • php

    Use of is_array, is_string ,is_real function – PHP

    echo ” Checking is_null() function”;
    $xp =’ram’;

    if(is_null($xp)){ // is_null function checks if variable is null or not
    echo “Null XP”;
    }
    elseif (is_string($xp)) // is_string function checks if variable is string
    {
    echo “Xp is string “;
    echo strval($xp); // strval function gives if variable is string
    }
    else if(is_array($xp)) // is_array function checks if variable is array
    {
    echo “xp is array”;
    print_r($xp);

    }
    else if(is_real($xp)) // is_real function checks if variable is float /decimal
    {
    echo “XP is real number”;
    }
    else if(isset($xp))
    {
    echo “its set”;
    }

    ?>

  • php

    Php array- how to search index of value , remove value key and reindex array

    array_search (“content value “,arrayname) //  gives the index number of value given in array

    $input1 = array(4,5,7,6,3,9,8); // let us consider its array

    $ser = array_search(5,$input1); // $ser will give value 1 means the index value  .. starts from 0

     //remove content from array   php

    unset($in[$ser]); // unset function with syntaxt

    // reindexing array php

    //array_splice($input1,0,0);

  • php

    PHP prime and composite number by is_init()

    A prime number = exactly divisible by same number and by 1 only  eg. 5 divisble by 5 and 1 only

    A composite number = number exactly divisible  by other number  other  than one and itsself. eg . 4  divided by 2 also ther than 4,1.

    Special PHP function used is  is_int() It returns true or false depending on variable value is integer or not

    <?php
    for($i=2;$i<18;$i++)
    {
    $count = 0;
    $z = $i/2;
    if(is_int($z)){
    for($j=2;$j<=$i/2;++$j)
    {
    if($i%$j==0){
    $count=$count+1;
    }
    }
    }
    else{
    $z=explode(‘.’,$z);
    $y = $z[0];
    for($j=2;$j<=$y;++$j)
    {
    if($i%$j==0){
    $count=$count+1;
    }
    }
    }
    if ($count==0)
    { echo $i.”is prime <br>”;}
    else
    { echo $i.”is composite <br>”; }
    }
    ?>
    

    ?>

    OUTPUT2is prime 
    3is prime 
    4is composite 
    5is prime 
    6is composite 
    7is prime 
    8is composite 
    9is composite 
    10is composite 
    11is prime 
    12is composite 
    13is prime 
    14is composite 
    15is composite 
    16is composite 
    17is prime