John P. Looney wrote:
> On Mon, Jan 19, 2004 at 05:22:11PM +0000, Dave O Connor mentioned:
>>>In my experience, perl is a lot easier to modularise, a lot clearer for some
>>things (i.e. calling $object->munge() instead of
>>doCertainProccessPHPHooray($object)).
>> Er, you can do $object->munge() in PHP, if you write the class etc.
>> That said, I love it's class definitions. You can just make a class with
> a nice strict class definition...and later it'll accept any typos and the
> like in your code:
>> class service {
> var $name;
> var $host;
> var $port;
> }
>> $object=new service;
>> $object->name="eric";
> $object->host="localhost";
> $object->poooort="29";
>> and it'll work with no warnings. Wonderful. Anyone know if this will be
> fixed in PHP5 ?
This is a fundamental attribute of the language, allowing you to
dynamically create variables associated with the class. The same
is true for Python. But you can quite easily enforce "strictness".
You might be able to use the same technique for php?
class Strict:
def __setattr__(self, name, value):
if hasattr(self.__class__,name):
self.__dict__[name]=value
else:
names = [x for x in self.__class__.__dict__.keys()
if not x.startswith('__')]
names.sort()
message = ("Class %s is strict: only attributes %s can be
set" %
(self.__class__.__name__, names))
raise AttributeError,message
class Mine(Strict):
a=1
mine=Mine()
mine.a=2
mine.b="error"
--
Pádraig Brady - http://www.pixelbeat.org
--- Following generated by rotagator ---
Process managment
ps -A #show all processes
ps -Af #show all processes with full command line
ps -Al #show all processes with extra info
ps -A --forest #show all processes and associated hierarchy
You can search the process list using grep, and send
signals using the command `kill -num pid`. The default
num is 15 (SIGTERM). `kill -l` will give a list.
Note kill -9 should never be used in normal operation.
--
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!