Re: Why does my class require the public accessor for my member?
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Tue, 16 Sep 2008 17:20:32 -0400
jmDesktop wrote:
On Sep 16, 12:45 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:jmDesktop wrote:On Sep 16, 11:47 am, Curtis <dye...@xxxxxxxxx> wrote:First of all, display_errors="stdout" is invalid. It is eitherjmDesktop wrote:Thanks. I left out the equals, but I have changed it to this:Consider:As Jerry has explained, it's not "display_errors on", it's
<?php
echo "start";
class myClass
{
public $connection;
function getme()
{
$this->connection = "test";
return $this->connection;
}
}
$database = new myClass();
$mytest = $database->getme();
echo $mytest;
echo "done";
?>
If I remove the "public $connection" above and have it just as
"$connection," I get nothing. Nothing loads, not start, done,
nothing, no html tags, no errors, nada. Make me thinks it's an error,
but when I use error_reporting, I get nothing also. If I put the
public modifier back in I get the results. I thought I could make
$connection private and access it from my accessor, getme().
What am I doing wrong? And, why doesn't php complain if I did my
class wrong? Thank you.
display_errors = On
Also, if you want to make class members private, use the "private"
keyword. Within a class definition, you have to precede property
declarations with a visibility keyword, or "var", which is equivalent
to "public", and exists for compatibility with PHP4. All of this info
is readily available in the PHP docs:
<URL:http://php.net/manual/en/language.oop5.visibility.php>
Example:
class Foo {
private $bar;
function getBar() {
return $this->bar;
}
}
--
Curtis- Hide quoted text -
- Show quoted text -
; To output errors to STDERR with CGI/CLI:
;display_errors = "stderr"
;
; Default
;
display_errors = "stdout"
and have tried
display_errors = On
(no quotes)
but I never get the errors. Don't know why. I have restarted the
httpd server after making the change. Maybe IIS doesn't like it.
It's probably me.
display_errors=on or display_errors=off
Second of all, ensure you're changing the correct php.ini. phpinfo()
will show you which php.ini you're actually using, and the status of
display_errors.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================- Hide quoted text -
- Show quoted text -
You were correct. I was not using right php.ini. Sorry for bothering
everyone. Thank you for your help.
No trouble - it's a common problem in this newsgroup :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- References:
- Why does my class require the public accessor for my member?
- From: jmDesktop
- Re: Why does my class require the public accessor for my member?
- From: Curtis
- Re: Why does my class require the public accessor for my member?
- From: jmDesktop
- Re: Why does my class require the public accessor for my member?
- From: Jerry Stuckle
- Re: Why does my class require the public accessor for my member?
- From: jmDesktop
- Why does my class require the public accessor for my member?
- Prev by Date: Re: Why does my class require the public accessor for my member?
- Next by Date: Re: PHP MySQL object question
- Previous by thread: Re: Why does my class require the public accessor for my member?
- Next by thread: zend guard
- Index(es):
Relevant Pages
|