Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,441
    Thanks
    15
    Thanked 0 Times in 0 Posts

    in oop -- how can i call a function within itself

    I have a function called

    get_breadcrumb($mode)

    how can i call the function within the function.
    like

    $bc = get_breadcrumbs("mymode");

    this function is in a class and the line of code above is not working.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    $rets = $this->method();
    PHP Code:
    <?php
    class blah{
        function 
    blah(){
          echo 
    $this->get_breadcrumbs();
        }

        function 
    get_breadcrumbs(){
          echo 
    'blah';
        }
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    to call any class method or variable use
    PHP Code:
    $this->methodname();
    $this->variablename 
    so in your case this would be
    PHP Code:
    $bc $this->get_breadcrumbs("mymode"); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •