用PHP在OOP上需要一个指针 [英] need a pointer on OOP with php
问题描述
你好,
i需要让我的网络内容更多OO。
i有一个项目在工作,我们正在移植到互联网,我和
开始学习php这样做。
项目现在是大小,代码重复使用并粘贴所有
结束它。我打算用更好,更干净的代码做一个好的重写。
所以我想要合并一些课程。
所以我有一些问题。
i我在eclipse上编写和在linux上发表文章。
i写了一个简单的类(例如在一本书中)
它有点像这样:
类客户
{
var $ name;
函数get_name()
{
返回$ this-name;
}
函数set_name($ new_name)
{
$ this-name = $ new_name;
}
}
我的解析器抱怨字段声明没有被公开,
私有或受保护。
什么是这个怎么说?
另一个问题....
如果我创建一个客户对象,比如有人登录该网站。可以
我将该对象传递给会话变量中的每个页面吗?比如从
登录页面,用户可以在没有我一遍又一遍编码
声明的情况下移动网站吗?
还是有更好的方法来解决这个问题吗?
这里还是新手。
谢谢。
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 ?
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 ?
or is there a better way to go about this ?
still a newbie here.
thanks.
推荐答案
名称;
函数get_name()
{
return
name;
function get_name()
{
return
this-name;
}
函数set_name(
this-name;
}
function set_name(
new_name )
{
new_name)
{
这篇关于用PHP在OOP上需要一个指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!