How do you get PHP, Symlinks and __FILE__ to work together nicely?

前端 未结 6 1687
既然无缘
既然无缘 2020-12-02 15:19

On localhost. I have the following directory structure:

/share/www/trunk/wp-content/plugins/otherfolders

/share/www/portfolio/wp-content/s

6条回答
  •  天命终不由人
    2020-12-02 16:09

    In some case its possible to change working dir and use getenv('PWD'):

    $root = dirname(dirname(dirname(getenv('PWD'))));
    if (file_exists($root.'/wp-load.php')) {
        // WP 2.6
        require_once($root.'/wp-load.php');
    }
    

    And change working directory before run this code:

    cd /var/www/wp-content/themes/twenty_twelve/ && php script.php
    

提交回复
热议问题