Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
6 | function _print( $string = NULL ) { |
||
|
|||
7 | if ( 'cli' == php_sapi_name() ) { // PHP is running in terminal |
||
8 | $line_end = PHP_EOL; |
||
9 | } else { |
||
10 | $line_end = '<br/>'; |
||
11 | } |
||
12 | |||
13 | if ( ! empty( $string ) ) { |
||
14 | $file = basename( $_SERVER["PHP_SELF"] ); |
||
15 | $output = date( 'd-m-Y_H:i:s ' ) . "[$file] $string $line_end"; |
||
16 | } else { |
||
17 | $output = $line_end; |
||
18 | } |
||
19 | |||
20 | print ( $output ); |
||
21 | } |
||
22 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: