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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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 12:01:30 2024 UTC