Reputation: 1690
Hi all I have a quick question about the construction of objects in PHP. I'm currently using the Zend framework to make a small test application to familiarize myself with the Zend way of doing things. However I have come across an error that is unfamiliar to me. In my controller I create the object $student like so:
$student = new Application_Model_Student();
However doing this causes my page to dump a 500 error and no debugging output. My constructor for this model doesn't actually do anything but print "Hello Creation" out. Here's my code for the model:
<?php
class Application_Model_Student
{
protected $_lastName;
protected $_firstName;
protected $_email;
protected $_concentration;
protected $_yearEntered;
public function __construct()
{
print "Hello Creation";
}
}
?>
Is there something wrong with my constructor? Or something in the way that I call it?
Upvotes: 1
Views: 326
Reputation: 12778
Ensure that you have set you APPLICATION_ENV
to 'development'
so that you can see the error message.
If you still get a white screen, then there's a syntax error in code before this file. turn on error_reporting and error_logging in your php.ini file and look in the error log file created.
Upvotes: 0
Reputation: 505
The only thing I can think of is that the autolader can't find your class and is throwing an exception; resulting in the 500 error.
Two ways to check this:
include
your filetry{}catch{}
to see if it is the autoloader(actually there's many more ways to check but these are a quick two).
Also don't bother closing the ?>
in your class file, can often have whitespace after it causing you header issues in the longer term.
Upvotes: 1