3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * class.MarsLogger.php * * CreatedBy: dbuchanan@cotterweb.net * CreatedOn: 4/3/15 * * Requires: _variables.php (BatchProcessLogging) * * This class created for MarketResearch, to simplify logging to BatchProcess and Email Alerts * */ ///Required for doing batchProcessLogging require_once '_variables.php'; /* ------------------------------------------------------------- */ /* * This class handles logging, emailing alerts, tracking debug, env, site, name stuff */ /* ------------------------------------------------------------- */ class MarketResearch_logger { protected $env; protected $debug=0; protected $site; protected $name; protected $admin_email='techadmin@cotterweb.net'; protected $dev_email='dbuchanan@cotterweb.net'; protected $batchProcessLogging; protected $finish_comment = array(); public function getSite() { return $this->site; } public function getEnv() { return $this->env; } /* public function getDebug() { return $this->debug; } */ public function getAdminEmail() { if($this->getEnv()=='dev') return $this->dev_email; else return $this->admin_email; } public function alreadyRunning() { /* See if cron is already running */ $exec_results = array(); exec("ps -ef | grep \"{$this->name}*{$this->getSite()}\" | grep -v grep | wc -l", $exec_results); return $exec_results; } protected function initLog($name) { $this->name=$name; $this->batchProcessLogging = new BatchProcessLogging($name, 'CRON'); } protected function setDebug($debug) { $this->debug=$debug; } public function startLog() { if($this->debug==0) $this->batchProcessLogging->logBatchStart(); else if($this->debug==1) { $this->batchProcessLogging->logBatchStart(); echo "\nStart Market Research Import"; } else { echo "\nStart Market Research Import"; } } public function logComment($message) { if($this->debug==0) $this->batchProcessLogging->logBatchComment($message); else if($this->debug==1) { $this->batchProcessLogging->logBatchComment($message); echo "\n$message"; } else { echo "\n$message"; } } public function addFinishComment($message) { array_push($this->finish_comment,$message); } public function sendEmailFinish($message) { $recipients = $this->getAdminEmail(); $subject = $this->site. ' Success: '.$this->name; $from = 'From: ' . $this->site . ' Cron Results'; $email_body = $this->site . ' '. $message; mail($recipients, $subject, $email_body, $from); } public function sendEmailAlert($message) { $recipients = $this->getAdminEmail(); $subject = $this->site. ' Problem Alert: '.$this->name; $from = 'From: ' . $this->site . ' Cron Results'; $email_body = $this->site . ' '. $message; mail($recipients, $subject, $email_body, $from); } public function endLog($message) { if($this->debug==0) { $this->batchProcessLogging->logBatchFinish($message . $this->batchProcessLogging->getElapsedBatchExecutionTime(true), 0, 0); } else if($this->debug==1) { foreach($this->finish_comment as $m) { $this->logComment($m); } $this->batchProcessLogging->logBatchFinish($message . $this->batchProcessLogging->getElapsedBatchExecutionTime(true), 0, 0); var_dump($this->finish_comment); echo "\n$message END LOG"; } else { var_dump($this->finish_comment); echo "\n$message"; } } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: require_once(): open_basedir restriction in effect. File(_variables.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uLBqV on line 14 Warning: require_once(_variables.php): Failed to open stream: Operation not permitted in /in/uLBqV on line 14 Fatal error: Uncaught Error: Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV:14 Stack trace: #0 {main} thrown in /in/uLBqV on line 14
Process exited with code 255.
Output for 8.0.13
Warning: require_once(_variables.php): Failed to open stream: No such file or directory in /in/uLBqV on line 14 Fatal error: Uncaught Error: Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV:14 Stack trace: #0 {main} thrown in /in/uLBqV on line 14
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.33
Warning: require_once(_variables.php): failed to open stream: No such file or directory in /in/uLBqV on line 14 Fatal error: require_once(): Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV on line 14
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Warning: require_once(): open_basedir restriction in effect. File(_variables.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uLBqV on line 14 Warning: require_once(_variables.php): failed to open stream: Operation not permitted in /in/uLBqV on line 14 Fatal error: require_once(): Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: main(_variables.php): failed to open stream: No such file or directory in /in/uLBqV on line 14 Fatal error: main(): Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/uLBqV on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/uLBqV on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/uLBqV on line 22
Process exited with code 255.

preferences:
343.87 ms | 401 KiB | 459 Q