View previous topic :: View next topic |
Author |
Message |
egoo -
Joined: 22 Jan 2008 Posts: 16
|
Posted: Tue Jan 22, 2008 6:40 pm Post subject: PHP5 Instruction SELF:: |
|
|
class MyColorEnumClass{
const RED = "Red";
const GREEN = "Green";
const BLUE = "Blue" ;
function printBlue()
{
print self::BLUE;
}
}
print MyColorEnumClass::RED;
$obj = new MyColorEnumClass();
When I 'm running this script it prints only "Red", provided it have to print
"Red" and "Blue". I use PHPDesigner 2007 Professional. There are a FILE option which is situated between optrions REPLACE and PROJECT in the toolbar. When I click File>JUMP TO DECLARATION there the instruction SELF:: DOES NOT APPEAR. But I don't know what I have to do. Please , help me. Thank you in advance.:) |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Tue Jan 22, 2008 11:07 pm Post subject: |
|
|
This PHP is a little over my head, but it seems you never call the printBlue() function. Might this be why it doesn't do anything??? _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Wed Jan 23, 2008 12:29 am Post subject: Re: PHP5 Instruction SELF:: |
|
|
As pkSML pointed out you are not calling the printBlue() function
The following code should work.
Code: | class MyColorEnumClass{
const RED = "Red";
const GREEN = "Green";
const BLUE = "Blue" ;
function printBlue()
{
print self::BLUE;
}
}
print MyColorEnumClass::RED;
$obj = new MyColorEnumClass();
[b]$obj->printBlue();[/b] //Added |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
|