简体   繁体   中英

I want to use functions in php class. How to use them?

I know the autoload mechanism, but I don't want to use it (_autoload() or spl_autoload_register),I want to simply php function files.But this doesn't work.

System:

php 7.3.x
nginx : 1.15.x

file:

| - index.php
| - Code
     |- Code.php
     |- Medoo.php
     |- HelperDateTime.php
     .....

Code.php:

class Code{

     public function Run(){
         include "./Medoo.php";
         include "./HelperDateTime.php";
         ....
     }
}

index.php:

require 'Code.php';
Code::Run();

// medoo not work
$database = new medoo();
print_r($database);

php Beginners, please advise :)

Index.php

<?php
include "Code/Medoo.php";
include "Code/HelperDateTime.php";
require 'Code.php';
Code::Run();

// medoo will work
$database = new medoo();
print_r($database);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM