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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: junkmail at lawrencebiblechapel dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC