|
Posted by Silvio Porcellana on 09/27/05 18:18
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
[Back to original message]
|