Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   PHP (http://www.flasher.ru/forum/forumdisplay.php?f=20)
-   -   Include path (http://www.flasher.ru/forum/showthread.php?t=44704)

Tagore 27.04.2003 13:07

Include path
 
PHP код:

<? $success = @include_once(dirname(__FILE__)."/elem/config.inc.php"); 
if (!
$success) { echo "Include failed"; } ?>

Или

PHP код:

 <?php 

  
function getPath() { 
      
     
// get position of current file 
     
$path = $GLOBALS["PATH_INFO"]; 
     
// save a few nanaseconds, has this been done before, 
     // has the global variable been set ? 
     
if (!isset($definedPath)) { 
        
// is file in root already ? 
        
if (strrpos($path,"/")!=0) { 
           
// there is probably a quicker way to count 
         // the "/"s in the path 
          
$path=explode("/",$path); 
           
$s=""; 
         for (
$i=0;$i<count($path)-1;$i++) { 
              if (
$path[$i]!="") { 
                 
// add the number of "../"s required 
                 
$s.="../"; 
            } 
           } 
           
// declare a global variable so you dont have to 
           // do this again, and return the variable 
           
global $definedPath; 
          
$definedPath=$s; 
           return 
$definedPath; 
        } 
    } else { 
        
// just return what it worked out before, function 
        // only really runs once 
        
return $definedPath; 
     } 
  } 
   
  include 
getPath() . "my_include_path/header.inc"; 
  include 
getPath() . "includes/somethingelse.inc"; 
  
//above file is at mydomain.com/includes/somethingelse.inc 
  
include getPath() . "includes/footer.inc"; 

?>


Crazy 27.04.2003 14:19

Тебе еще не надоело спамить с этой темой по форумам?

Tagore 27.04.2003 20:34

Я еще ответа не нашел, вот и сюда пришел спросить. Не умничай, помоги, если можешь. :rolleyes:

Crazy 27.04.2003 21:14

А где ты нашел вопрос в своем письме? :)


Часовой пояс GMT +4, время: 07:34.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.