You are here: Re: need a pointer on OOP with php « PHP Programming Language « IT news, forums, messages
Re: need a pointer on OOP with php

Posted by nephish on 08/06/06 19:01

First off, thanks for the links and the info, especially the first
link.
Thats what i needed to know.

The system at work uses php4, the system i use at home has php5.
well, suppose i could upgrade works server, but still, passing
everything around as a stream may be a bit more complicated than i
wanted to, but still may be worth it.

i do appreciate the info. Though, i know more about what i am dealing
with.

shawn



Rik wrote:
> nephish wrote:
> > Hello there,
> >
> > i am getting to need to make my web stuff more OO.
> > i have a project at work that we are porting to the internet, and i
> > started learning php to do so.
> > the project is now mamoth is size, and code is reused and pasted all
> > over it. I plan to do a good re-write using better, and cleaner code.
> > So i want to incorporate some classes.
> >
> > So i have some questions.
> >
> > i am writing in eclipse and phpedit on linux.
> > i wrote a simple class ( by example in a book )
> >
> > it goes a little something like this:
> >
> > class Customer
> > {
> > var $name;
> >
> > function get_name()
> > {
> > return $this-> name;
> >
> > }
> > function set_name($new_name)
> > {
> > $this-> name = $new_name;
> > }
> > }
> >
> > my parser complains about field declarations not being declared
> > public, private, or protected .
> > what is this talking about ?
>
> 1. If you're serious about OO, learn what they mean.
> 2. http://nl3.php.net/manual/en/language.oop5.visibility.php It was
> introduced in PHP in version 5, in 4 it will not work. From the manual:
> "Note: The PHP 4 method of declaring a variable with the var keyword is no
> longer valid for PHP 5 objects. For compatibility a variable declared in php
> will be assumed with public visibility, and a E_STRICT warning will be
> issued."
>
> > another question....
> >
> > if i create a customer object when say, someone logs into the site.
> > Can i pass that object to each page in session variables ? like from
> > the login page, can the user move about the site without me coding the
> > declarations over and over ?
>
> You can:
> http://nl3.php.net/manual/en/function.serialize.php
> http://nl3.php.net/manual/en/language.oop5.autoload.php
>
> You might want to ask yourself wether this is really needed, and why exactly
> some simple variables aren't enough.
>
> > or is there a better way to go about this ?
>
> Just keep in mind OO isn't neccesarily better, and www.php.net is a great
> source where you would have found answers to this questions very quickly. Be
> sure to read the user contributed notes.
>
> Grtz,
> --
> Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация