PHP: cannot declare class because the name is already in use

前端 未结 6 990
南方客
南方客 2020-12-29 19:14

I have 5 scripts:

  1. database.php
  2. parent.php
  3. child1.php
  4. child2.php
6条回答
  •  情书的邮戳
    2020-12-29 19:38

    you want to use include_once() or require_once(). The other option would be to create an additional file with all your class includes in the correct order so they don't need to call includes themselves:

    "classes.php"

    include 'database.php';
    include 'parent.php';
    include 'child1.php';
    include 'child2.php';
    

    Then you just need:

    require_once('classes.php');
    

提交回复
热议问题