PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, I'm new to the board but have been looking as a guest for a while. I am new to PHP OOP coding and I am having a problem implementing a class. I have searched to forum but have not been able to find anything that will help me solve this. I have been able to get this bit of code working on a single page but not as a function or within a class. I am parsing an XML file and want to return an array of certain tag contents. As I said I can get it working when not inside of a class. I don't get any kind of error message just no data in the array.
<?php
$objTest = new parseTest('ORDE3238.xml');
$anotherTest = $objTest->getOrderNum();
if (!$anotherTest)
{
echo "No Data was returned.";
}
else
{
print_r($anotherTest);
}
?>
webrock wrote:Hi, I'm new to the board but have been looking as a guest for a while. I am new to PHP OOP coding and I am having a problem implementing a class. I have searched to forum but have not been able to find anything that will help me solve this. I have been able to get this bit of code working on a single page but not as a function or within a class. I am parsing an XML file and want to return an array of certain tag contents. As I said I can get it working when not inside of a class. I don't get any kind of error message just no data in the array.
<?php
$objTest = new parseTest('ORDE3238.xml');
$anotherTest = $objTest->getOrderNum();
if (!$anotherTest)
{
echo "No Data was returned.";
}
else
{
print_r($anotherTest);
}
?>
Thanks for any help
Walt
As a rule, class names should be in caps, such as: ParseText, but it shouldn't make any difference for this. If you called your constructor parseText would that make any difference?