Re: Pre global configuration

From: Date: Tue, 27 Sep 2005 15:18:18 +0000
Subject: Re: Pre global configuration
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-223286@lists.php.net to get a copy of this message
Jake Gardner wrote: > This is a stretch and I doubt you can do this very easily, but I was > wondering if there is a way to define behaviors that happen throughout > a script before execution for example if the OS is windows, all > strings are terminated with \r\n, if Linux, then \n without adding > addition ifs throughout the code. > I don't know if it may help you, but why don't you set a constant in a config file included by all your scripts to the CRLF value you want (if you want it dependant on the OS you can use http://php.net/php_uname) and then you append this constant to all your strings? Example: - config.inc.php: define('CRLF', ( strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? "\r\n" : "\n" ) ); - other_script.php require_once 'config.inc.php'; .... $string = 'Hi! My name is Pippo!' . CRLF; Or something like this... ;-) Cheers Silvio

« previous php.general (#223286) next »