What does this php construct mean: $html->redirect(“URL”)?

前端 未结 5 776
名媛妹妹
名媛妹妹 2021-01-19 18:21

I\'ve seen this \"-> \" elsewhere used in php. One of the books I used to learn PHP has this in it, but it is never explained. What does it do, how does it work!

The

5条回答
  •  梦毁少年i
    2021-01-19 18:47

    $html in your case is not a variable but a class. Just google for 'PHP class tutorial'. redirect in this is case is a member function, which should probably contain similar code:

    class html {
        function redirect($url) {
             echo '';
             exit;
        }
    }
    

    This will allow to construct a class from your PHP script like this:

    $html = new html;
    

    And you will be able to call it's member:

    $html->redirect("www.stackoverflow.com");
    

提交回复
热议问题