unable to call a class in a different file

Hi, I am unable to call a function in a php class which is in a different file. Here is the code for both the files. Any help will be appreciated…I am just trying to learn php…


<?php class HelloWorld { function HelloWorld() { } function GetString() { return "HelloWorld"; } } ?>

Calling php : test.php

<?php echo "Starting.."; $helloObj = new HelloWorld(); $rtr = $helloObj->GetString(); echo "Return from class" ; echo $rtr; ?>

When i access test.php from the browser, it prints out “Starting…” but does not go beyond that…can anyone tell me why ?
I am using php 5


where is ur include? has to be on top of the class initialisation.

if errors arn’t showing up error_reporting(E_ALL); should help

echo “Starting…”;
$helloObj = new HelloWorld();
$rtr = $helloObj->GetString();
echo “Return from class” ;
echo $rtr;

Sponsor our Newsletter | Privacy Policy | Terms of Service