😆When to use DIRECTORY_SEPARATOR in PHP code path (ok)

https://stackoverflow.com/questions/26881333/when-to-use-directory-separator-in-php-code

Because in different OS there is different directory separator. In Windows it's \ in Linux it's /. DIRECTORY_SEPARATOR is constant with that OS directory separator. Use it every time in paths.

require_once dirname(__FILE__).DIRECTORY_SEPARATOR . './../../../wp-config.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'inc/options.php';

C:\xampp82\htdocs\scholarsprep\wp-config.php

if ( !defined( 'WP_THEME_DIR_CT' ) ) {
  define( 'WP_THEME_DIR_CT', ABSPATH . 'wp-content' . DIRECTORY_SEPARATOR . 'themes'  . DIRECTORY_SEPARATOR . 'kadence-child' . DIRECTORY_SEPARATOR);
}

Last updated