Error when setting constants

Asked

Viewed 20 times

0

 PHP Warning: include_once(): Failed opening '/classes/class.rslib.php' for inclusion (include_path='.;C:\php\pear\') in on line 26

I logged this error in the log, I debugged and found the only file that does this include. At debugging time everything worked correctly, but still do not know the cause of the error.

Apparently at some point the dirname(__FILE__) returned null. There is an alternative to dirname(_FILE__) ?

        <?php       
    /*
     * Redsand Wordpress Library
     * Version: 2.1.4
     * Modify: 12/29/2014
     * Author: RedSand Team
     *
     */
    session_start();

    /// CONST //\
    define('RS_LIB_PATH', dirname(__FILE__));
    define('RS_LIB_URL', strpos(RS_LIB_PATH, 'wp-content/plugins') > 0 ? plugins_url('rslib', RS_LIB_PATH) : get_stylesheet_directory_uri() . '/rslib');

    define('RS_META_KEY_PREFIX', 'rs-');

    define('RS_NOT_SET', '__RS_NOT_SET__');

    define('LANGUAGES_PATH',  get_template_directory() . '/languages');

    define('RS_VERSION', '2.1.4');

    /// RS CLASS ///

    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
        include_once(RS_LIB_PATH . '/classes/class.rslib.php');
        global $RS;
        $RS = new RS(); $RS->init();
    }
    else{
        wp_die('Sorry, Your site only run with PHP 5.3.0 or higher but current PHP version is '. PHP_VERSION . '.<br/>Please contact system administrator to upgrade it.');
    }

1 answer

2

Try it like this:

define('RS_LIB_PATH', __DIR__);
  • It worked, but what’s the difference between the two ?

  • The DIR returns the current directory. is equivalent to dirname(FILE). does the same thing. see php net

  • Is there any situation that DIR and FILE return ' ' or Null ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.