 |
รบกวนช่วยอธิบายคำสั่ง ini_set("include_path", $_SERVER['DOCUMENT_ROOT']."/"); ให้หน่อยครับ |
|
 |
|
|
 |
 |
|
ต้องเข้าใจว่าแยกเป็น 2 ส่วนนะครับ
ini_set เป็นคำสั่งที่ฝังไว้ใน ไฟล์ php เอาไว้ Config ค่าที่ของระบบ ทำให้เราไม่ต้องไปยุ่งกับ php.ini
ส่วน ini_set("include_path", $_SERVER['DOCUMENT_ROOT']."/");
เป็นการ SET root path หรือ base path ครับ
ประโยชน์ สามารถเข้าถึงไฟล์ได้โดยตรง โดยที่เราไม่ต้องมานั่งงง ว่าต้อง ../ ออกมากี่ครั้ง หรือ เข้าไปที่ไฟล์ไหน พาธไหน มันจะเป็นเหมือน
http://www.ชื่อเว็บ.com/ ให้เราน่ะครับ
ที่เหลือเราก็เติมเอา
เช่นไฟล์รูปเราอยู่ใน img/pic1.gif
พอรวมกับ basepath แล้วก็จะได้
http://www.ชื่อเว็บ.com/img/pic1.gif
บางเว็บที่เวลาเรา Viewsource แล้วเจอพาธเต็มๆ เค้าก็ใช้หลักการทำนองนี้น่ะครับ
ปล. ถ้าเรา echo $_SERVER['DOCUMENT_ROOT'] ออกมาจะได้ root path ของไฟล์ที่อยู่ณ.ปัจจุบัน หรือ พาธของไฟล์ที่กำลังเรียก $_SERVER['DOCUMENT_ROOT'] อยู่ครับ
|
ประวัติการแก้ไข 2010-10-27 16:02:36
 |
 |
 |
 |
Date :
2010-10-27 16:01:30 |
By :
adaaugusta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้า config.inc.php คับ
มีปัญหา บรรทัดที่ 17 ขึ้นเออเรอร์ว่า
Parse error: syntax error, unexpected T_STRING in D:\AppServ\www\projectsilk\source\library\config.php on line 17
จะต้องแก้อย่างไรครับ
จากโค๊ตที่ใช้ด้านล่างนี้
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
// start the session
session_start();
// database connection config
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '1234';
$dbName = 'phpwebco_shop';
// setting up the web root and server root for
// this shopping cart application
$thisFile = str_replace('\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);
define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
// these are the directories where we will store all
// category and product images
define('CATEGORY_IMAGE_DIR', 'images/category/');
define('PRODUCT_IMAGE_DIR', 'images/product/');
// some size limitation for the category
// and product images
// all category image width must not
// exceed 75 pixels
define('MAX_CATEGORY_IMAGE_WIDTH', 75);
// do we need to limit the product image width?
// setting this value to 'true' is recommended
define('LIMIT_PRODUCT_WIDTH', true);
// maximum width for all product image
define('MAX_PRODUCT_IMAGE_WIDTH', 300);
// the width for product thumbnail
define('THUMBNAIL_WIDTH', 75);
if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
foreach ($_POST as $key => $value) {
$_POST[$key] = trim(addslashes($value));
}
}
if (isset($_GET)) {
foreach ($_GET as $key => $value) {
$_GET[$key] = trim(addslashes($value));
}
}
}
// since all page will require a database access
// and the common library is also used by all
// it's logical to load these library here
require_once 'database.php';
require_once 'common.php';
// get the shop configuration ( name, addres, etc ), all page need it
$shopConfig = getShopConfig();
?>
|
 |
 |
 |
 |
Date :
2010-11-03 11:56:42 |
By :
ยาคับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$thisFile = str_replace('\', '/', __FILE__);
แก้เป็น
Code (PHP)
$thisFile = str_replace('\\', '/', __FILE__);
|
 |
 |
 |
 |
Date :
2010-11-03 13:20:18 |
By :
adaaugusta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|