1. I've started a massive SPAM purge, any accounts that have spammed are being removed, also for a short period new user signups are disallowed until the SPAM cleaning is finished.

PHP Basics-11 Easy Steps

Discussion in 'PHP' started by midlandi, Nov 18, 2007.

  1. Bedi

    Bedi Member

    Joined:
    Sep 16, 2014
    Messages:
    15
    Likes Received:
    32
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon

    is it use of multidim..array,,,,,,,,thanks for clear the confusion.............
  2. Bedi

    Bedi Member

    Joined:
    Sep 16, 2014
    Messages:
    15
    Likes Received:
    32
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
  3. Bedi

    Bedi Member

    Joined:
    Sep 16, 2014
    Messages:
    15
    Likes Received:
    32
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,
    why we use intrface.............


    Ans:we use the interface for specifying the functions in interfaces to force the programmer to make implementation of specified functions in a class.


    for example:

    <?php
    interface person
    {

    function show();
    function show1();
    }

    class friend implements person{
    function show(){
    echo "I am BHOOPENDRA","<br>";
    }

    function show1(){
    echo "I am DINESH","<br>";
    }

    }

    $call=new friend;
    $call->show();
    $call->show1();
    ?>
  4. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,
    Today we will learn about what is abstract class.


    for example-

    <?php
    abstract class gurgaonhousing{

    function show(){
    echo "I am Gurgaon housing,<br>";
    }

    abstract function show1();

    }


    class gurgaonhousing1 extends gurgaonhousing{

    function show1(){
    echo "hello,again";
    }
    }


    $gur=new gurgaonhousing1;
    $gur->show();
    $gur->show1();
    ?>



    output:

    I am Gurgaon housing,
    hello,again
    Bedi, Naruka Kumar and Richen ji like this.
  5. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hello,

    we will learn about some string functions:
    example---

    <?php
    echo "The test string is 'no problem'.<br>";
    echo "'no problem is ",strlen("no problem")," characters long<br>";
    echo "The substring substr('no problem',3,7) is ",substr("no problem",3,7),"<br>";
    echo "the word 'problem' is at position ",strpos("no problem","problem"),"<br>";
    echo "replacing 'problem' with 'problems' gives : ",substr_replace("no problem","problems",3,9),"<br>";
    echo "using ascii codes : ",chr(65),chr(66),chr(67),"<br>";
    echo "uppercasing the the first letter ",ucfirst("no problem"),"<br>";
    echo "in upper case : ",strtoupper("no problem"),"<br>";
    echo "in lower case : ",strtolower("NO PROBLEM"),"<br>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;'no problem' trimmed is : ",trim(" no problem"),"<br>";
    echo "reversed : ",strrev("no problem"),"<br>";
    echo "there are ",substr_count("no problem","o")," o's in 'no problem'.";
    ?>


    output:

    23
    16
    HI I AM GURGAON HOUSING
    hi i am gurgaon housing
    Hi i am gurgaon housing
    Hi I am Gurgaon Housing
    I am Gurgaon Housing
    Hi I am Gurgaon Panthouse
    2
    Bedi, Naruka Kumar and Richen ji like this.
  6. Richen ji

    Richen ji Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    40
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Leh ladakh
    Hello,
    we can merge two arrays like-

    <?php
    $ladakh=array("Ladakh","Art","Palace");
    $ladakh1=array("Ladakhi","famous","art");
    $ladakh12=array_merge($ladakh,$ladakh1);

    echo "<pre>";
    print_r($ladakh12);

    ?>

    output:

    Array
    (
    [0] => Ladakh
    [1] => Art
    [2] => Palace
    [3] => Ladakhi
    [4] => famous
    [5] => art
    )
    Bedi, Naruka Kumar and Sandeep Hatria like this.
  7. Richen ji

    Richen ji Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    40
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Leh ladakh
    Hello,

    how can we differenciate between arrays contents...

    example:

    <?php
    $ladakh=array("Ladakh","art","palace");

    $ladakh1=array("Ladakh","handicrafted","palace");

    $ladakh2=array_diff($ladakh,$ladakh1);

    foreach($ladakh2 as $k=>$v){

    echo "key : ",$k," value : ",$v;

    }
    ?>

    output:
    key : 1 value : art
    Bedi, Naruka Kumar and Sandeep Hatria like this.
  8. Naruka Kumar

    Naruka Kumar Member

    Joined:
    Sep 15, 2014
    Messages:
    13
    Likes Received:
    33
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Delhi
    Hi,
    what is overriding..
    answer is here----
    example:
    <?php
    class person
    {
    var $name;
    function set_name($data)
    {
    $this->name=$data;
    }
    function get_name()
    {
    return $this->name;
    }
    }


    class friend extends person
    {
    var $name;
    function speak()
    {
    echo $this->name," is speaking.<br>";
    }

    function set_name($data)
    {
    $this->name=strtoupper($data);
    }
    }

    echo "<h2>Before using the FINAL keyword</h2><br>";
    echo "Creating your new friend ........<br>";
    $friend=new friend;
    $friend->set_name("Susan");
    $friend->speak();

    ?>

    output:

    Before using the FINAL keyword

    Creating your new friend ........
    SUSAN is speaking.
    Bedi, Richen ji and Sandeep Hatria like this.
  9. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,
    Conditional function ..........


    <?
    $condition=true;
    $condition1=true;


    if($condition){

    gurgaonhousing();

    }

    function gurgaonhousing(){
    echo "Hi,from gurgaonhousing.<br>";
    }


    if($condition1){

    gurgaonhousing1();

    }

    function gurgaonhousing1(){
    echo "Hi,from gurgaonhousing1.<br>";
    }

    $condition2=false;

    if($condition2){

    gurgaonhousing2();

    }


    function gurgaonhousing2(){
    echo "Hi,from gurgaonhousing2.<br>";

    }
    ?>



    output:

    Hi,from gurgaonhousing.
    Hi,from gurgaonhousing1.
    Bedi, Naruka Kumar and Richen ji like this.
  10. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    hi,
    CONSTRUCTOR

    <?php

    class gurgaonhousing{
    function __construct($data){
    echo "I am from first constructor ... ",$data,"<br>";
    }
    }
    $obj=new gurgaonhousing("Ram");
    ?>


    output:
    I am from first constructor Ram
    Bedi, Naruka Kumar and Richen ji like this.
  11. Richen ji

    Richen ji Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    40
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Leh ladakh
    Hi,

    Checking for data types validation---

    <?
    $name="Ramesh";
    $intiger=5;

    if(is_int($name)){
    echo $name," yes it is intiger.<br>";
    }

    else{
    echo $name," it is no integer.<br>";
    }

    if(is_int($intiger)){
    echo $intiger," yes it is intiger.<br>";
    }

    else{
    echo $intiger," it is no integer.<br>";
    }

    ?>


    output:

    Ramesh it is no integer.
    5 yes it is intiger.
    Sandeep Hatria, Bedi and Naruka Kumar like this.
  12. Richen ji

    Richen ji Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    40
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Leh ladakh
    Hi,

    validate string and float data types----

    <?
    $name=8.99998;
    $string="ram";

    if(is_float($name)){
    echo $name," yes it is float.<br>";
    }

    else{
    echo $name," it is no float.<br>";
    }

    if(is_string($string)){
    echo $string," yes it is intiger.<br>";
    }

    else{
    echo $string," it is no integer.<br>";
    }

    ?>


    output:

    8.99998 yes it is float.
    ram yes it is intiger.
    Sandeep Hatria, Bedi and Naruka Kumar like this.
  13. Naruka Kumar

    Naruka Kumar Member

    Joined:
    Sep 15, 2014
    Messages:
    13
    Likes Received:
    33
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Delhi
    Hi,
    I am Naruka.

    Checking ASCII CODE

    <?

    echo chr(65),"<br>";
    echo chr(66),"<br>";
    echo chr(67),"<br>";
    echo chr(68),"<br>";

    ?>


    output:

    A
    B
    C
    D
    Richen ji, Sandeep Hatria and Bedi like this.
  14. Naruka Kumar

    Naruka Kumar Member

    Joined:
    Sep 15, 2014
    Messages:
    13
    Likes Received:
    33
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Delhi
    Hi,

    creating function variable--

    <?
    $name="red";
    $name1="white";

    $name();
    function red(){
    echo "Hi,i am from red.<br>";

    }

    $name1();

    function white(){
    echo "Hi,i am from white.<br>";

    }
    ?>


    output:

    Hi,i am from red.
    Hi,i am from white.
    Richen ji, Sandeep Hatria and Bedi like this.
  15. Bedi

    Bedi Member

    Joined:
    Sep 16, 2014
    Messages:
    15
    Likes Received:
    32
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,
    what is the working of array_pop().

    example:

    <?
    $bedi=array(1,2,3,4,5);
    $bedi1=array_pop($bedi);
    echo "<pre>";
    print_r($bedi);

    ?>


    output:

    Array
    (
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    )
    Richen ji and Sandeep Hatria like this.
  16. Bedi

    Bedi Member

    Joined:
    Sep 16, 2014
    Messages:
    15
    Likes Received:
    32
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,

    what is the use of array_shift();

    <?
    $bedi=array(1,2,3,4,5);
    $bedi1=array_shift($bedi);
    echo "<pre>";
    print_r($bedi);
    ?>

    output:

    Array
    (
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
    )
    Richen ji and Sandeep Hatria like this.
  17. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon

    thanks,,,,,but what about array_shift();;;;;;;
    Bedi and Richen ji like this.
  18. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon


    thanks,,,,buddy
    Bedi and Richen ji like this.
  19. Sandeep Hatria

    Sandeep Hatria Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    26
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Gurgaon
    Hi,
    <?
    $gurgaonhousing=array("delhi"=>"central park on sale","gurgaon"=>"DLF properties","noida"=>"New property projects");
    echo "<pre>";
    print_r($gurgaonhousing);

    print_r(array_flip($gurgaonhousing));
    ?>



    output:

    Array
    (
    [delhi] => central park on sale
    [gurgaon] => DLF properties
    [noida] => New property projects
    )s
    Array
    (
    [central park on sale] => delhi
    [DLF properties] => gurgaon
    [New property projects] => noida
    )
    Bedi and Richen ji like this.
  20. Richen ji

    Richen ji Member

    Joined:
    Sep 15, 2014
    Messages:
    15
    Likes Received:
    40
    Trophy Points:
    13
    Gender:
    Male
    Location:
    Leh ladakh



    so nice..filipping
    Bedi likes this.

Share This Page