Page 1 of 1

[SOLVED] Help with include

Posted: Thu Sep 01, 2005 2:47 pm
by HeavyWave
I just do the following:

Code: Select all

include("/conf/modules/authorize/main.php.inc"); 

$auth = new mod_authorize;
And this leads to an error, I don't know the exact message because .php file is used as a template handler, so I simply get clear-page.
Everything works without $auth = new mod_authorize;

The main.php.inc file is:

Code: Select all

<?

class mod_authorize
{
 	function show()
 	{
 		return '<h2>Hello World!</h2><br>';
 	}
}

?>
q

Posted: Thu Sep 01, 2005 2:57 pm
by Ree
try

Code: Select all

$auth = new mod_authorize();

Posted: Thu Sep 01, 2005 3:00 pm
by raghavan20
calling a class should always be followed by open and closed parantheses even if there is no parameter to be passed to the constructor.

Posted: Thu Sep 01, 2005 3:13 pm
by HeavyWave

Code: Select all

$auth = new mod_authorize();
Doesn't help. I've made constructor. Made a testing file and now I get error: Fatal error: Cannot instantiate non-existent class: mod_authorize

Posted: Thu Sep 01, 2005 3:20 pm
by Ree
Maybe <? ?> is a prob? Try <?php ?>.

Posted: Thu Sep 01, 2005 3:23 pm
by raghavan20
It means that the class could not be found in the file.
why dont you post your code mate???
if you have defined the class in a separate file; make sure you include the name of the file properly in the file where you instantiate an object of the class you defined. :)

Posted: Thu Sep 01, 2005 3:43 pm
by Ree
He doesn't seem to get include error, so the file must be ok. From what he posted, it's really difficult to find what could be wrong.

Posted: Fri Sep 02, 2005 8:12 am
by HeavyWave

Code: Select all

<?php

class mod_authorize
{
        function mod_authorize()
        {
                ;
        }

         function show()
         {
                 return '<h2>Hello World!</h2><br>';
         }
}

?>

Code: Select all

<?

include_once("http://antropogeon.loresit.com/conf/modules/authorize/main.php.inc");

$some = new mod_authorize();
echo $some->show();

?>
That's all code. I get error: "Fatal error: Cannot instantiate non-existent class: mod_authorize in /home/loresit/public_html/antropogeon/test.php on line 5"

Posted: Fri Sep 02, 2005 8:16 am
by shiznatix
first you don't that full path name, just a require("file.inc.php"); or whatever. second you dont do $some = new class_name(); you do

Code: Select all

$some = new class_name;

Posted: Fri Sep 02, 2005 9:09 am
by HeavyWave
Thank's, now it's working.