473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PHP Version 4.3.2 OO Hole???

I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at http://www.phpbuilder.com/board/show...7#post10505527
and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.

Phil
Jul 17 '05 #1
6 1853
Phil Powell <so*****@erols.com> wrote:
I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at http://www.phpbuilder.com/board/show...7#post10505527 and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.


The PHP code you posted is equivalent to the following java code:

class Foo
{
public static String foo="Foo";

public static String bar()
{
return this.foo;
}
}

IOW It doesn't work.

And since you can't access a variable in a static way (in php4), there
is no equivalent for:
class Foo
{
public static String foo="Foo";

public static String bar()
{
return Foo.foo;
}
}

With http://www.php.net/manual/en/functio...class-vars.php one can
access the defaults but the example clearly shows that it's not the
solution to your "problem".

--

Daniel Tryba

Jul 17 '05 #2
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at http://www.phpbuilder.com/board/show...7#post10505527 and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.

Phil


/**
* Retrieve $this->nullExemptionArray[$section][$elementName] (useful
mainly for classes that call Accepter statically)
*
* @access public
* @param mixed $section
* @param mixed $elementName
* @return mixed $this->nullExemptionArray[$section][$elementName]
*/

Hmmm...very interesting OO technique here. Care to explain what the code
does?
Jul 17 '05 #3
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<ae********************@comcast.com>...
"Phil Powell" <so*****@erols.com> wrote in message
news:1c**************************@posting.google.c om...
I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at

http://www.phpbuilder.com/board/show...7#post10505527
and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.

Phil


/**
* Retrieve $this->nullExemptionArray[$section][$elementName] (useful
mainly for classes that call Accepter statically)
*
* @access public
* @param mixed $section
* @param mixed $elementName
* @return mixed $this->nullExemptionArray[$section][$elementName]
*/

Hmmm...very interesting OO technique here. Care to explain what the code
does?


That in and of itself does nothing in PHP, but is parsed by
PHPDocumentor (http://www.phpdocumentor.com) for building Javadoc-like
documents for PHP.

Phil
Jul 17 '05 #4
The PHP code I'm trying to write, however, will be the equivalent of this:

public class Foo {

public Foo() {
doSomethingNonStaticHere();
}

public static final String[] fooArray = "{'blah', 'whatever', 'etc.'}";

public static String getFooValue(int i) {
return fooArray[i];
}

public void doSomethingNonStaticHere() {
// BLAH BLAH BLAH
System.out.println("Blah blah blah");
}

}

out.println(Foo.getFooValue(1));

Phil

Daniel Tryba <ne****************@canopus.nl> wrote in message news:<c6**********@news.tue.nl>...
Phil Powell <so*****@erols.com> wrote:
I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at http://www.phpbuilder.com/board/show...7#post10505527

and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.


The PHP code you posted is equivalent to the following java code:

class Foo
{
public static String foo="Foo";

public static String bar()
{
return this.foo;
}
}

IOW It doesn't work.

And since you can't access a variable in a static way (in php4), there
is no equivalent for:
class Foo
{
public static String foo="Foo";

public static String bar()
{
return Foo.foo;
}
}

With http://www.php.net/manual/en/functio...class-vars.php one can
access the defaults but the example clearly shows that it's not the
solution to your "problem".

Jul 17 '05 #5
Phil Powell <so*****@erols.com> wrote:
The PHP code I'm trying to write, however, will be the equivalent of this:

public static final String[] fooArray = "{'blah', 'whatever', 'etc.'}";


This is a final array, so can't be changed... in this case
http://www.php.net/manual/en/functio...class-vars.php actually is the
answer.

--

Daniel Tryba

Jul 17 '05 #6
Phil Powell wrote:
I might have found a rather bad hole in PHP OO design for Versions
4.3.2 involving static class-level rendering, like in Java. Please
read my thread at
http://www.phpbuilder.com/board/show...687a2615fec46e
dec19&postid=10505527#post10505527 and please, if you have a counter to this, I'm all ears. Based on
what I have found so far, nothing seems to address this, not even in
the manual.


PHP 4 doesn't have static object properties. So, when you call a class's
method without instantiating the object first, it is executed just like any
other function; the class gives it only a specific namespace. Since there is
no object, there can't be a reference to it, and therefore the $this
variable is not set.

You are correct, PHP4 is miles away from Java when it comes to completeness
of its OO features. PHP5 is bound to amend a lot of the differences.

Berislav

--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Chung Leong | last post by:
Building web sites with PHP is easy. Building secured web sites--in any language--is hard. The end result is many PHP sites with security issues. I thought therefore it would be a good idea to put...
16
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example,...
133
by: Jane Withnolastname | last post by:
I have a web page that uses an unordered list (<UL>) and the LH (list header) tag. I know LH is a valid tag because it is clearly defined by the W3C here:...
24
by: Bob Alston | last post by:
Could develop web pages that would interact with the access/jet database - like DAP but without the security flaw??? One of Access' competitors (Filemaker Pro as I recall) touts its EASY way to...
19
by: Ken | last post by:
Hi, I need to modify an existing application that's written in C, C++ and Visual C++ so the application can be released as a time limited trial version, also the modifications must prevent the...
4
by: Patrick Olurotimi Ige | last post by:
Huge security hole in .NET: Java creator http://www.zdnet.com.au/news/security/0,2000061744,39179932,00.htm *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
0
by: Scooter | last post by:
We received a copy of SQL 2005 at a recent SF Launch event. We have SA on SQL Standard and from what I hear we will not see our Open License copy of SQL until mid December or so. The Launch...
19
by: Blair P. Houghton | last post by:
I'm just learning Python, so bear with. I was messing around with the webbrowser module and decided it was pretty cool to have the browser open a URL from within a python script, so I wrote a...
3
by: Chuck | last post by:
Hello, Does Dotnet 2.0 Framework still have the security hole that Dotnet 1.1 Framework had regarding HTTP-Post method for web services? TIA
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.