放棄 PHP4 的 Object Reference

編寫、設計網頁與程式。

版主: hamu278, 銘仔

版面規則
  • 本版面亦可以討論網頁寄存公司

放棄 PHP4 的 Object Reference

文章Puff » 2008-09-25, 19:57

頭痛緊放唔放棄 PHP4 既 Object Reference 好 :D

因為我諗依家大多數人都用 PHP5 啦 :lol:

我怕日後 PHP6 PHP7 PHP8 PHP9 blahblahblah 會取消兼容 Class name 做 Function name 既 Function 做 Constructor :roll: (?

如果搞兼容Mode (得閒無事) 就要改成咁

代碼: 選擇全部
<?php
// Do not forget to extend the class Core.
class core_class_example extends Core
{
   function core_class_example(&$base)
   {
      /** Throw the base object to class Core and let Core::Core to do the things.
        * More beautiful than:
         $this->base = &$base;
        */
      parent::Core($base);
   }

   function __constructor(&$base)
   {
      $this->core_class_example($base);
   }

   function a_function($username, $password)
   {
      /** Register a shortcut for the other core classes we needed.
        * Call it by $this->[class_name]->a_function();
        * More beautiful than:
         $this->base->[class_name]->a_function();
        * Don't use this function at the constructor ;P
         $this->register_class('modules');
        */

      $this->base->halt('This is an example.');
   }
}?>
最後由 Puff 於 2008-09-25, 20:01 編輯,總共編輯了 1 次。
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-25, 20:00

仲有好多網存迫人用 PHP 4,例如我用緊既 WChost…

取消兼容 Class name 做 Function name 既 Function 做 Constructor

我無乜研究過 class,只係知基本野,咩黎 :oops: 有冇 code :oops:
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-25, 20:01

bananasims 寫:仲有好多網存迫人用 PHP 4,例如我用緊既 WChost…

取消兼容 Class name 做 Function name 既 Function 做 Constructor

我無乜研究過 class,只係知基本野,咩黎 :oops: 有冇 code :oops:

加左 :o

It means
代碼: 選擇全部
class Blah {
function Blah() { print "Blah!!!"; }
}


用 $sth = new Blah; 就自動excute Blah::Blah();

PHP5 依家加左 Class::__constructor(); 功用同上

唔知用邊個好 :o
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-25, 20:10

哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-25, 20:32

bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲

:cry:

我對加唔加 Visibility Keywords ( public private protected ) 都有保留

PHP4 唔識編譯 :!:

Example Code of extends (唔tidy既):
代碼: 選擇全部
class Parent { function Orz() { print 'Parent::Orz();<br />'; } }
class Child extends Parent { function Child { print ' Call Parent in Child:'; parent::Parent(); print '<br /><br />Child::Child();'; } }
$i = new Child;
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-25, 20:46

Puff 寫:
bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲

:cry:

我對加唔加 Visibility Keywords ( public private protected ) 都有保留

PHP4 唔識編譯 :!:

Example Code of extends (唔tidy既):
代碼: 選擇全部
class Parent { function Orz() { print 'Parent::Orz();<br />'; } }
class Child extends Parent { function Child { print ' Call Parent in Child:'; parent::Parent(); print '<br /><br />Child::Child();'; } }
$i = new Child;

等 PHP 4 沒落…
原來係 new Child 唔係 Parent :cry:
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-25, 20:54

bananasims 寫:
Puff 寫:
bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲

:cry:

我對加唔加 Visibility Keywords ( public private protected ) 都有保留

PHP4 唔識編譯 :!:

Example Code of extends (唔tidy既):
代碼: 選擇全部
class Parent { function Orz() { print 'Parent::Orz();<br />'; } }
class Child extends Parent { function Child { print ' Call Parent in Child:'; parent::Parent(); print '<br /><br />Child::Child();'; } }
$i = new Child;

等 PHP 4 沒落…
原來係 new Child 唔係 Parent :cry:

Child 繼承 Parent 嘛 :oops:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章ntf » 2008-09-25, 21:40

bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲


唔係 $this->__constructor(); 係 __construct

例:
代碼: 選擇全部
class example{
       function __construct($string) {
             echo $string;
   }
}

$x=new example('hello world");


順道一提 interface 都幾好用
ntf
天王星會員
 
文章: 36
註冊時間: 2008-05-25, 12:02

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 16:36

Thanks for the answer by ntf :lol:

PHP4 is now stopped supporting by the official so I think I will rewrite a part of my forum-program into PHP5 OO-style :lol:

Now look forward to PHP6 :lol:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 16:45

Confusing in PHP5.3's namespace :oops:

Will the namespace extends to the other files?

I mean when I set the namespace as "Orz" in Orz.class.php,

and I set the namespace as "Zro" in Zro.class.php.

If I include them into Orzzro.php (include Orz.class.php first),

Will the variables in Orzzro.php belongs to the "Zro" namespace?

---

Trying to find out the answers by GG :lol:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-26, 16:46

ntf 寫:
bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲


唔係 $this->__constructor(); 係 __construct

例:
代碼: 選擇全部
class example{
       function __construct($string) {
             echo $string;
   }
}

$x=new example('hello world");


順道一提 interface 都幾好用

PHP 4 可唔可以咁寫?
Puff 寫:Thanks for the answer by ntf :lol:

PHP4 is now stopped supporting by the official so I think I will rewrite a part of my forum-program into PHP5 OO-style :lol:

Now look forward to PHP6 :lol:


我估你都唔會再用 register_globals 同埋 magic_quotes_gpc :D
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-26, 16:48

Puff 寫:Confusing in PHP5.3's namespace :oops:

Will the namespace extends to the other files?

I mean when I set the namespace as "Orz" in Orz.class.php,

and I set the namespace as "Zro" in Zro.class.php.

If I include them into Orzzro.php (include Orz.class.php first),

Will the variables in Orzzro.php belongs to the "Zro" namespace?

---

Trying to find out the answers by GG :lol:

outdate 咗添,仲以為 namespace 係 PHP 6 既 feature :cry:
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 17:07

bananasims 寫:
ntf 寫:
bananasims 寫:哦,明白
我而家先知 PHP 4 都有 constructor…
可能兩個都要保留 :oops:
代碼: 選擇全部
class test
{
   function test()
   {
      $this->__constructor();
   }

   function __constructor()
   {
      // code
   }
}


無乜 PHP 5 開發經驗,唔知可唔可以 $this->__constructor();
仲有,個 extends 我一向唔識用 :oops: 次次用親都話搵唔到個 object
以我理解,係整個新既 class 去將入面既 function 同埋 variable 加落去個 object 到
對 class 無乜研究,我都係識嗰啲 protect private protected 嗰啲


唔係 $this->__constructor(); 係 __construct

例:
代碼: 選擇全部
class example{
       function __construct($string) {
             echo $string;
   }
}

$x=new example('hello world");


順道一提 interface 都幾好用

PHP 4 可唔可以咁寫?
Puff 寫:Thanks for the answer by ntf :lol:

PHP4 is now stopped supporting by the official so I think I will rewrite a part of my forum-program into PHP5 OO-style :lol:

Now look forward to PHP6 :lol:


我估你都唔會再用 register_globals 同埋 magic_quotes_gpc :D

Well,

I am using something like request_var() in phpBB3 :lol:

My request_var() function :
代碼: 選擇全部
mixed Base::request_var(string $param_name [, mixed $default_var [, string $type]])


Defaultly search parameter in $_REQUEST :lol:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 17:09

Uh.

Magic functions like __construct() and __destruct() is the thing of PHP5-OOP.

Of course PHP4 can't use it :lol:

As well as interface :P

P.S. I'm going to build a SVN and upload my program onto it. :oops:
最後由 Puff 於 2008-09-26, 17:10 編輯,總共編輯了 1 次。
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-26, 17:10

用 request_var 統一晒都幾好,可以 check 埋有冇 magic_quotes_gpc 再 stripslashes
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 17:12

bananasims 寫:用 request_var 統一晒都幾好,可以 check 埋有冇 magic_quotes_gpc 再 stripslashes

Thanks for you remind.

I forgot to program this thing : stripping slashes when magic_quotes switched on :oops:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-26, 17:17

Puff 寫:
bananasims 寫:用 request_var 統一晒都幾好,可以 check 埋有冇 magic_quotes_gpc 再 stripslashes

Thanks for you remind.

I forgot to program this thing : stripping slashes when magic_quotes switched on :oops:

有冇搞 deregister_globals?
register_globals 好膠
代碼: 選擇全部
$_SESSION['signature'] = 'a';
$signature = 'b';
var_dump($_SESSION['signature']);

output string (0) b…
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 17:19

It seems that PHP6 will remove the support of this thing
代碼: 選擇全部
$something = "My name is [b]{$name}[/b], I like to play [b]{$games}[/b]";


I'm not sure but someone says that on his/her blog :oops:
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章Puff » 2008-09-26, 17:20

bananasims 寫:
Puff 寫:
bananasims 寫:用 request_var 統一晒都幾好,可以 check 埋有冇 magic_quotes_gpc 再 stripslashes

Thanks for you remind.

I forgot to program this thing : stripping slashes when magic_quotes switched on :oops:

有冇搞 deregister_globals?
register_globals 好膠
代碼: 選擇全部
$_SESSION['signature'] = 'a';
$signature = 'b';
var_dump($_SESSION['signature']);

output string (0) b…

I have not program it :lol:

But I'm developing in an environment without (disabled) magic_quotes and register_globals :lol:

This is not important than develop the core so I planned it to be the last todo-items.
Wholehearted plastics are stranger than fiction.
Puff
木星會員
 
文章: 343
註冊時間: 2008-08-30, 05:22

Re: 放棄 PHP4 的 Object Reference

文章bananasims » 2008-09-26, 17:25

Puff 寫:It seems that PHP6 will remove the support of this thing
代碼: 選擇全部
$something = "My name is [b]{$name}[/b], I like to play [b]{$games}[/b]";


I'm not sure but someone says that on his/her blog :oops:

對我無乜影響 :D

我以前就寫
代碼: 選擇全部
$something = 'My name is [b]'.$name.'[/b], I like to play [b]'.$games.'[/b]';

而家就
代碼: 選擇全部
$something = 'My name is [b]' . $name . '[/b], I like to play [b]' . $games . '[/b]';


Discuz! 好興咁
代碼: 選擇全部
$something = "My name is [b]$name[/b], I like to play [b]$games[/b]";
影像.從心 At the heart of the ímage
bananasims
太陽會員
 
文章: 13541
註冊時間: 2005-09-22, 00:00

下一頁

回到 [B1] 網頁製作、程式編寫與介面設計



誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron