看板 [ PHP ]
討論串[討論] 能不能這樣判實體化成功與否?
共 4 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 3→)留言3則,0人參與, 最新作者JYHuang (夏天到了,冷不起來了說)時間11年前 (2012/09/26 14:59), 編輯資訊
1
0
0
內容預覽:
class test{. public $boo;. public functoin __construct($bool){. $this->bool = $bool;. return $bool;. }. public function __toString(){. return $this->b
(還有123個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者gpmm (銀色)時間11年前 (2012/09/26 16:17), 編輯資訊
1
0
0
內容預覽:
等等,我記得 construct 的 return 是沒有意義的,. 因為它實際上 new class 只會丟回 object 啊…. 其實看你的例子還是不很明白你要做什麼 o_Oa". 另外如果會有「實體化失敗」的情況那應該是直接噴 error 了吧?. --. 發信站: 批踢踢實業坊(ptt

推噓2(2推 0噓 5→)留言7則,0人參與, 最新作者JYHuang (夏天到了,冷不起來了說)時間11年前 (2012/09/26 17:01), 編輯資訊
1
0
0
內容預覽:
class file{. public $file_path;. public $file_name;. public $success=false;. public functoin __construct($full_name){. if (file_exists($full_name) &&
(還有290個字)

推噓0(0推 0噓 10→)留言10則,0人參與, 最新作者gpmm (銀色)時間11年前 (2012/09/26 20:12), 編輯資訊
0
0
0
內容預覽:
嘛…我覺得可能沒辦法 XDD. 正要出門沒時間細想,丟一個直覺上的「少一行」解. if ($file = new file ($path) && $file->success) {. // do something. }. --. 我路上再想想 XD. --. 發信站: 批踢踢實業坊(ptt.c
首頁
上一頁
1
下一頁
尾頁