ThaiSEOBoard.com

พัฒนาเว็บไซต์ => CMS & Free Script => ข้อความที่เริ่มโดย: แมวมีเจ้าของ ที่ 24 มีนาคม 2012, 18:11:28



หัวข้อ: ../ ตำแหน่งไฟล์ และ Include
เริ่มหัวข้อโดย: แมวมีเจ้าของ ที่ 24 มีนาคม 2012, 18:11:28
ผมเพิ่งหัดทำเว็บน่ะครับ ยังไม่เข้าใจเรื่อง การแสดงตำแหน่งแบบสั้นๆ ภายในเว็บ เรียกว่ายังไง หรือพูดยังไงไม่รู้นะ
ไม่รู้ว่าเรียกว่าอะไร จะไปค้นหาถาม Google ก็ไม่รู้ว่าจะพิมพ์ว่าอะไร รบกวน Guru ในบอร์ดแล้วกันครับ

ต้องการรู้เกี่ยวกับตำแหน่งไฟล์ และวิธีใช้ include ครับผม

ตัวอย่างเช่น
Root - index.html       (เวลาดึงรูปจาก แฟ้ม Images ก็จะเป็น /Images/ABC.jpg ใช่ป่าวครับ)
     - Images (folder)
       - ABC.jpg
       - 123.jpg
     - Test (folder)
       - Test2 (Folder)
         - test.html    (เวลาดึงรูปจาก แฟ้ม Images จะเป็นยังไงครับ ../../Images/ABC.jpg แบบนี้ถูกไหมครับ)
     - DEFG (folder)
       - HIJKL (Folder)
         - index.html

ทีนี้ ผมอยากดึง หน้า test.html มาใส่ ใน index.html ในแฟ้มย่อย HIJKL ของแฟ้ม DEFG
ผมจะต้องใช้คำสั่งยังไงครับ

โค๊ด:
 <?php include("test.html"); ?>
<?php include("../test.html"); ?>
<?php include("../../test.html"); ?>

ผมใส่ url แบบเต็มๆ มันก็ขึ้น ประมาณนี้
โค๊ด:
Warning: include(http://www.xxx.com/Test/Test2/test.html) [function.include]: failed to open stream
ถ้าเปิดแต่ url มันก็แสดงเนื้อหาได้อยู่ไม่ error แต่พอเอา url ไปใส่ตรงโค้ด Include มันก็เป็นแบบนี้

ผมใช้คำสั่งผิดหรือเปล่าครับ มีวิธียังไงบ้าง แนะนำด้วยครับ ขอบคุณครับ


หัวข้อ: Re: ../ ตำแหน่งไฟล์ และ Include
เริ่มหัวข้อโดย: UnLock UnlimiT ที่ 24 มีนาคม 2012, 18:15:54
../  คือลงไป 1 ชั้น

./folder  คือขึ้นไป 1 ชั้น


หัวข้อ: Re: ../ ตำแหน่งไฟล์ และ Include
เริ่มหัวข้อโดย: แมวมีเจ้าของ ที่ 24 มีนาคม 2012, 18:21:22

+1 ขอบคุณมากๆครับ พอจะเข้าใจบ้างแล้ว  :wanwan020:


หัวข้อ: Re: ../ ตำแหน่งไฟล์ และ Include
เริ่มหัวข้อโดย: SpiderManKing ที่ 24 มีนาคม 2012, 19:03:18


../  คือลงไป 1 ชั้น

./folder  คือขึ้นไป 1 ชั้น



../ คือขึ้นไป 1 ชั้น ไม่ใช่ลงไป 1 ชั้นนะ


Relative Path URLs

Relative paths change depending upon what page the links are located on. There are several rules to creating a link using the relative path:

links in the same directory as the page have no path information listed
filename
sub-directories are listed without any preceding slashes
weekly/filename
links up one directory are listed as
../filename



link ใน directory เดี่ยวกัน
  filename

link ใน sub direcotory
  subdirecotoryname/filename

link ขึ้นไป 1 ชั้น
 ../filename

link ขึ้นไป 2 ชั้น
 ../../filename

ใช้ key word ค้นหาคือ "Relative Path " หรือ  "Absolute path  "

ลองดูตัวอย่าง http://www.communitymx.com/content/article.cfm?cid=230ad