|
Posted by Steve on 03/01/06 11:57
On Tue, 28 Feb 2006 11:04:59 -0800, julian_m wrote:
> I'm having problems with include. I wrote a small example which shows
> what's going on...
>
> I should say that the problems started after I moved to a shared
> server. All was working fine in my local server...
>
>
> file test.php
> ---------------------------------------------------
> <?php
>
> echo '<html>';
> echo '<head>';
> echo '</head>';
> echo '<body>';
>
> echo "including inc.php<br>";
>
> include("http://my_site/inc.php");
>
> echo "inc was included<br>";
>
> $clsIncClass = new ClsIncClass;
>
> echo '</body>';
> echo '</html>';
>
> ?>
>
> file inc.php
> ---------------------------------------------------
> class ClsIncClass {
> function ClsIncClass() {
> echo "ClsIncClass constructor<br>";
> }
> }
>
>
> result in browser:
>
> including inc.php
> class ClsIncClass { function ClsIncClass() { echo "ClsIncClass
> constructor
> "; } }inc was included
>
> Fatal error: Cannot instantiate non-existent class: clsincclass in
> /home/ke000067/public_html/test1.php on line 21
>
> Note that it seems that inc.php was included as if it were a text file,
> but as you can imagine, it's not my intention...
>
>
> So, i decided to change
>
> include("http://IP_of_my_site/inc.php");
>
> to
>
> include($_SERVER['DOCUMENT_ROOT']."/my_site/inc.php");
>
> but the result was
>
> including inc.php
>
> including inc.php
>
> Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
> to open stream: No such file or directory in
> /home/ke000067/public_html/test1.php on line 15
>
> Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
> to open stream: No such file or directory in
> /home/ke000067/public_html/test1.php on line 15
>
> Warning: main(): Failed opening
> '/opt/apache/htdocs/~ke000067/public_html/inc.php' for inclusion
> (include_path='.:/opt/apache/lib/php') in
> /home/ke000067/public_html/test1.php on line 15
> inc was included
>
> Fatal error: Cannot instantiate non-existent class: clsincclass in
> /home/ke000067/public_html/test1.php on line 23
>
>
> Anyone could give me some hints?
>
> regards - jm
Well, I don't know about anyone else, but I put <? ?> round php code in
included files. Would this make any difference?
Steve
Navigation:
[Reply to this message]
|