- Posts: 57
- Thank you received: 3
Resolve the error “Use of undefined constant DS”
10 years 11 months ago - 9 years 7 months ago #492
by Simpel
Resolve the error “Use of undefined constant DS” was created by Simpel
Resolve the error “Use of undefined constant DS” of require_once method in Joomla 3.0
In Joomla 1.5 to 2.5 we include directly the helper file or other file in the Joomla PHP code using require_once() method but in Joomla 3.0 you must defined the DS directory separator constant otherwise you getting error message.
<code>defined(\\\'_JEXEC\\\') or die(\\\'Restricted access\\\');
require_once (dirname(__FILE__).DS.\\\'helper.php\\\');</code>
Here is the right way to import your file using the DIRECTORY_SEPARATOR constant
<code>defined(\\\'_JEXEC\\\') or die(\\\'Restricted access\\\');
if(!defined(\\\'DS\\\')){
define(\\\'DS\\\',DIRECTORY_SEPARATOR);
}
require_once (dirname(__FILE__).DS.\\\'helper.php\\\');</code>
In Joomla 1.5 to 2.5 we include directly the helper file or other file in the Joomla PHP code using require_once() method but in Joomla 3.0 you must defined the DS directory separator constant otherwise you getting error message.
<code>defined(\\\'_JEXEC\\\') or die(\\\'Restricted access\\\');
require_once (dirname(__FILE__).DS.\\\'helper.php\\\');</code>
Here is the right way to import your file using the DIRECTORY_SEPARATOR constant
<code>defined(\\\'_JEXEC\\\') or die(\\\'Restricted access\\\');
if(!defined(\\\'DS\\\')){
define(\\\'DS\\\',DIRECTORY_SEPARATOR);
}
require_once (dirname(__FILE__).DS.\\\'helper.php\\\');</code>
Last edit: 9 years 7 months ago by Simpel.
Please Log in or Create an account to join the conversation.