Return from include file

前端 未结 5 1056
醉酒成梦
醉酒成梦 2020-11-27 17:41

in PHP, how would one return from an included script back to the script where it had been included from?

IE:

1 - main script 2 - application 3 - included

5条回答
  •  抹茶落季
    2020-11-27 17:54

    includeme.php:

    $x = 5;
    return $x;
    

    main.php:

    $myX = require 'includeme.php'; 
    

    also gives the same result

    This is one of those little-known features of PHP, but it can be kind of nice for setting up really simple config files.

提交回复
热议问题