ThaiSEOBoard.com

พัฒนาเว็บไซต์ => Programming => ข้อความที่เริ่มโดย: workshop ที่ 13 กันยายน 2007, 13:33:34



หัวข้อ: ขอความช่วยเหลือ php เรื่อง nofollow
เริ่มหัวข้อโดย: workshop ที่ 13 กันยายน 2007, 13:33:34
ตามกระทู้นี้ครับ http://www.thaiseoboard.com/index.php/topic,14903.0.html

ผมลองทำดูโดยใช้

โค๊ด:
<?
$text = "which give the discerning audio enthusiast some respite in their travels, or, for the audiophile who accepts nothing less than the best, a world class entertainment system that?s worthy of any classy whip. Happy travels!</p><p>Nathan Kartchner is the Marketing Coordinator for Sewell Direct, a premium online retailer, where you can find the <a target="_new" href="http://sewelldirect.com/vr3-cd-player-usb-port-audio-input-mp3.asp">VR3 Car Stereo CD Player with USB Port and Auxiliary Connector</a>, the <a target="_new" href="http://sewelldirect.com/vr3-thumbdrive-dj-mp3-fm.asp">VR3 Thumbdrive Player/FM Transmitter</a>, and the <a target="_new" href="http://sewelldirect.com/Scosche-iPod-Bluetooth-Car-Kit.asp">Scosche iPod Wireless Bluetooth Car Kit</a>"

$pattern = '/<a href=/';
$replacement = '<a rel="nofollow" href=';
$text = preg_replace($pattern,$replacement, $text);
echo $text;
?>

มันติดตรงที่ใน $textมันมีเครื่องหมาย " อยู่เต็มไปหมด
เลยคิดว่า ถ้าผมนั่งไล่แก้ ผมไล่ใส่ rel="nofollow" ง่ายกว่าครับ

จึงอยากจะขอคำแนะนำด้วยครับเอายังไงดี


หัวข้อ: Re: ขอความช่วยเหลือ php เรื่อง nofollow
เริ่มหัวข้อโดย: EThaiZone ที่ 13 กันยายน 2007, 15:07:39
มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)


หัวข้อ: Re: ขอความช่วยเหลือ php เรื่อง nofollow
เริ่มหัวข้อโดย: desiger ที่ 13 กันยายน 2007, 15:21:01
มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)

EOF เพิ่งรู้อ่ะว่ามี และก้ใช้กันง่ายๆอย่างงี้ได้ด้วย

ขอบคุงครับ


หัวข้อ: Re: ขอความช่วยเหลือ php เรื่อง nofollow
เริ่มหัวข้อโดย: workshop ที่ 13 กันยายน 2007, 15:27:39
มี 2 วิธีครับ

1. ถ้าข้อความมี " มากๆ ก็หันมาใช้ ' ปิดหน้าหลังแทน เช่น
$text = '<a href="web.com">55</a>';

2. ใช้แบบนี้เลย

$text = <<<EOF
<a href="web.com">55</a>
EOF;

พอจะเก็ทปะครับ   :)


ขอบคุณมากๆ ครับ
กำลังปวดหัวอยู่เลย
ตอนนี้แก้ไขอยู่ติดขัดอะไรคงต้องรบกวนอีกครั้งครับ
ถ้าเป็นไปได้จะขอ msn ของคุณ EThaiZone ได้ไหมครับ
เห็นแจกหลายคนแล้ว ขอเพิ่มอีกซักคน