php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9304 require function generates error
Submitted: 2001-02-16 14:46 UTC Modified: 2004-10-19 15:34 UTC
From: junkmail at lawrencebiblechapel dot org Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.4 OS: WinME
Private report: No CVE-ID: None
 [2001-02-16 14:46 UTC] junkmail at lawrencebiblechapel dot org
in the documentation the following is noted:

require() is not actually a function in PHP; rather, it is a language construct. It is subject to some different rules than functions are. For instance, require() is not subject to any containing control structures.

I have found this statement ("not subject to any containing control structures") to NOT be true.  I get an error for the following:

class myclass()
{
    require("myfile.php")
};

I want to be able to include a function from another file that will become a method for the class.

Any suggestions?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-16 14:55 UTC] flash at drewnels dot net
this error happens on all these commands:

   include()
   include_once()
   require()
   require_once()
 [2001-02-16 15:10 UTC] flash at drewnels dot net
this error happens on all these commands:

   include()
   include_once()
   require()
   require_once()
 [2001-02-16 22:57 UTC] andre@php.net
no bug, it is simply not possible this way, only "var" and
"function" language constructs are allowed directly withing
class {}

the only way I see is passing your class and methods through
eval()

 [2004-10-19 15:34 UTC] junkmail at lawrencebiblechapel dot org
thanks
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC