|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38608 File include control system feature request
Submitted: 2006-08-26 15:45 UTC Modified: 2018-06-24 04:22 UTC
From: p3n4g473 at hotmail dot com Assigned: cmb (profile)
Status: No Feedback Package: *General Issues
PHP Version: 5.1.5 OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
17 + 47 = ?
Subscribe to this entry?

 [2006-08-26 15:45 UTC] p3n4g473 at hotmail dot com
I think PHP should include some sort of directive control system for determining what portions of a file are included when using the include()/include_once() and require()/require_once() functions from another file. For example, a directive to prevent inclusion of a block of code.

  // some code that should not be included

The code inside that block would only be parsed when executing the script file directly.

Obviously, this is not a particularly important feature. However I would find this very useful for adding testing code to include files, so that the includes can be called directly to test them.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-12 15:47 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: cmb
 [2018-03-12 15:47 UTC]
Well, how about using the following idiom instead:

  if (get_included_files() === 1) define('RUN_TESTS', true);


  if (RUN_TESTS) {
      // some code that should not be included
 [2018-03-12 15:52 UTC] spam2 at rhsoft dot net
i wouldn't put the test-code directly anyways

our structure is that every class has to have an identical called file which contains the test code and is included at calltime of the method test()

the test-suite running all that stuff is that way also aware when it returns -1 inteast 0/1 that the unit was not present and so they can be distributed independent as needed

  * Auto-Test Methode
  * @return int
  * @access public
 public function test(): int
  $basename = basename(__FILE__);
   return (int)require "{$this->cl_api->CONTENTLOUNGE_BASEDIR}/autotests/$basename";
   return -1;
 [2018-06-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 11:01:32 2024 UTC