473,386 Members | 1,779 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,386 software developers and data experts.

Class public function

I am running PHP version 4.3.11-dev:

The class as defined below does not work:

<?php

class hello {
public function printHello() {
echo "HELLO";
}
}

$obj = new hello;

$obj->printHello(); // does NOT print hello

?>

When i delete the 'public' keyword then the above works ok!

Is it maybe because 4.3.11-dev probably does not fully support classes?

Marcel

Dec 7 '05 #1
7 15038
Marcel wrote:
When i delete the 'public' keyword then the above works ok!

Is it maybe because 4.3.11-dev probably does not fully support classes?

Marcel


PHP Prior to version 5 does not
support access specifiers.

--
Etienne Marais
Cosmic Link
South Africa

Dec 7 '05 #2
PHP Prior to version 5 does not
support access specifiers.

--


Ok thanks, but is it a good idea then to build classes in PHP versions prior
to ver. 5 ?

Marcel
Dec 7 '05 #3
Marcel wrote:
PHP Prior to version 5 does not
support access specifiers.

--


Ok thanks, but is it a good idea then to build classes in PHP versions
prior to ver. 5 ?

Marcel


If you foresee using PHP 5 in the future,
preferably not. If you are starting clean,
now is the best time to jump onto the PHP 5
bandwagon (and I'd be looking on jealously).

--
Etienne Marais
Cosmic Link
South Africa

Dec 7 '05 #4
Marcel wrote:
PHP Prior to version 5 does not
support access specifiers.

--


Ok thanks, but is it a good idea then to build classes in PHP versions
prior to ver. 5 ?

Marcel


Actually it depends on yourself.

Are you strongly concerned with upward compatibility
or just curious if php 4 classes are 'even viable' ?

I have had a lot of fun with 'OO oriented PHP 4' but
an equal amount of misery due to unexpected limited
consistency and stability.

--
Etienne Marais
Cosmic Link
South Africa

Dec 7 '05 #5

PHP Prior to version 5 does not
support access specifiers.

--


Thanks for your advice Etienne,

Most PHP classes on the web i've seen do not use access-specifiers at
all.... is bthat to make them backwards compatible with earlier versions of
PHP.

What's PHP5's status right now? Is it allready broadly in use by the PHP
community or is it still relatively new?

Marcel
Dec 7 '05 #6
Marcel wrote:
PHP Prior to version 5 does not
support access specifiers.

--

Thanks for your advice Etienne,

Most PHP classes on the web i've seen do not use access-specifiers at
all.... is bthat to make them backwards compatible with earlier versions of
PHP.

What's PHP5's status right now? Is it allready broadly in use by the PHP
community or is it still relatively new?

Marcel

Both PHP 4 and PHP 5 are in use.

Having made the somewhat painful transition, I would recommend anybody
starting now to use PHP 5, especially if they think OO.

The OO model in PHP 4 is broken, not to put too fine a point on it.

Having said that, I suspect that not too many systems are using access
specifiers yet, because without 'friend classes', or some equivalent
mechanism, its usefulness is limited.

Colin
Dec 8 '05 #7
*** Marcel escribió/wrote (Wed, 7 Dec 2005 12:16:32 +0100):
What's PHP5's status right now? Is it allready broadly in use by the PHP
community or is it still relatively new?


In Unix-like boxes is difficult to upgrade PHP version. You have to compile
from sources, break package system and handle lots of library
incompatibilities. Also, Linux distros designed for servers tend to test
software for quite long before releasing it (for instance, current version
of Red Hat Enterprise Linux includes PHP 4.3.9 if I recall correctly).

So it's rather common to find old versions out there. Choosing a
development version is more a question of "where am I going to run my
scripts?".

In general, I tend to ignore the latest when I do web development. You
often depend on computers you can't control and are slow to upgrade (think
on CSS and web browsers). And it's also pretty common that fashionable
technologies of today are simply death three years later. I still regret
having learnt ASP ;-)
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Dec 10 '05 #8

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

Similar topics

2
by: Nancy | last post by:
I have the following situation and could use some advise. I have a Base Class CreditReport, classes BoatCreditReport and HomeCreditReport Inherit from CreditReport. I would like to have the...
3
by: jamie_m_ | last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error You must implement a default...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
0
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports...
6
by: Ken Foster | last post by:
Is it possible to return a class (not an instance of a class) from a function? For example (actually tried this code, it didn't work, but it's what I want sort of): Class EventMessage Public...
6
by: thomasp | last post by:
For those who gave advice on the shortfalls of my first attempt at writing a vb.net class, Thank You. I hope that I was able to apply some of your advice to this larger atempt. At first I didn' t...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
1
by: davebaranas | last post by:
I am able to serialize this but I get a null exception when I try to deserialize it back Even if I don't make any child classes it throws "Object reference not set to an instance of an object."...
3
by: TamusJRoyce | last post by:
Hello. This is my first thread here. My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic). My problem is that I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.