note 46292 added to function.include

From: Date: Wed, 06 Oct 2004 00:10:52 +0000
Subject: note 46292 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-78049@lists.php.net to get a copy of this message
Be aware that you can't do an include from within a class. For example I wanted to share some variables across several classes so tried to do it as an include: class Page { require ('shared/page/vars.inc'); ... } Will give the unilluminating error "Parse error: parse error, expecting T_OLD_FUNCTION' or T_FUNCTION' or T_VAR' or '}'' in /usr/local/www/vhosts/cps/sitemods/Page.php on line 29." Make a superclass instead, like so: class SharedPage { var $_sharedvar; } class Page extends SharedPage { require ('shared/page/vars.inc'); } ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46292 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46292&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46292&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78049) next »