 |
สอบถามการทำงานโค๊ด public function ตามโค๊ดด้านในหน่อยครับ |
|
 |
|
|
 |
 |
|
ติดปัญหาตอนไหนครับ การส่งค่าหรือว่าเรียกใช้ครับ
|
 |
 |
 |
 |
Date :
2015-02-19 06:44:41 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
public function watch_id($url){
preg_match('/v=(.+?)&+/', $url, $watch_id);
if(!$watch_id[1])
return false;
$this->player($watch_id[1],$width="",$height ='');
}
public function player($watch_id, $width = 560, $height = 315){
echo '<iframe width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $watch_id . '" frameborder="0">
</iframe>';
}
คิดว่าเค้าหมายความว่าอย่างนี้น่ะ
|
 |
 |
 |
 |
Date :
2015-02-19 11:41:36 |
By :
bunchuai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
public function watch_id($url)
กับ
function watch_id($url)
เหมือนกัน function ที่ไม่อยู่ใน class เป็น public หมดครับ
แต่ถ้าอยู่ใน class public จะเรียกใช้จากนอก class ได้ แต่ private ไม่ได้จะเรียกใช้เฉพาะใน class
อันนี้ความเข้าในแบบ คนเรียนน้อยครับ ผิดยังไงขอโทดที ครับ
public function player($watch_id, $width = 560, $height = 315)
function นี้จะรับค่า watch_id ,width,height
watch_id ต้องมีส่งมา
width ถ้าไม่มีค่าส่งมา มันจะ default 560
height ถ้าไม่มีค่าส่งมา มันจะ default 315
เช่น player(50) หรือ player(50,150,150)
|
ประวัติการแก้ไข 2015-02-19 12:02:38
 |
 |
 |
 |
Date :
2015-02-19 11:59:30 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|