简体   繁体   中英

Absolute path on shared hosting: Installing Smarty

I am trying to install smarty on my shared hosting plan. I have installed the smarty files on a sub domain that I will be using it for. I am attempting to define the SMARTY_DIR variable, but am not quite sure how to use the absolute hosting path that my web host has provided.

Here is my include path (according to cPanel, found in 'PHP settings')

.:/usr/lib/php:/usr/local/lib/php

Now, when I put the Smarty files in the sub domains directory, index.php and libs (directory) are on the same level. So my thoughts were to do something like:

define('SMARTY_DIR','.:/usr/lib/php:/usr/local/lib/php/libs/' );
require_once(SMARTY_DIR . 'Smarty.class.php');

Am I not doing this correctly? I am getting the obvious error that the file does not exist.

Any thoughts / advice is greatly appreciated.

For portability. You can use [__DIR__][1] or dirname(__FILE__)

You code will be something like, assuming smarty folder on the same level with current script.

define('SMARTY_DIR', __DIR__ . '/smarty/');
require_once(SMARTY_DIR . 'Smarty.class.php');
define('SMARTY_DIR','.:/usr/lib/php:/usr/local/lib/php/libs/' );

This is not a path, this are two pathes (separated by the path separator, on linux : , on win ; , available in PHP via the constant PATH_SEPARATOR ). include(_once) and require(_once) don't support this.

define('SMARTY_DIR','/usr/lib/php:/usr/local/lib/php/libs/' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM