How to use a PHP class from another file?

前端 未结 5 1675
庸人自扰
庸人自扰 2020-12-05 06:41

Let\'s say I\'ve got two files class.php and page.php

class.php



        
5条回答
  •  一个人的身影
    2020-12-05 07:03

    use

    require_once(__DIR__.'/_path/_of/_filename.php');
    

    This will also help in importing files in from different folders. Try extends method to inherit the classes in that file and reuse the functions

提交回复
热议问题