Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Making this answer consistent, as "Mechanism to log errors" would be useless with error_reporting=0.
Source Link
Your Common Sense
  • 158.2k
  • 42
  • 226
  • 374

I would usually go with the following code in my plain PHP projects.

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICTE_ALL); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(E_ALL); ini_set('display_errors', 0); ini_set('display_startup_errors', 0); ini_set('log_errors', 1); /*/ Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

I would usually go with the following code in my plain PHP projects.

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

I would usually go with the following code in my plain PHP projects.

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(E_ALL); ini_set('display_errors', 0); ini_set('display_startup_errors', 0); ini_set('log_errors', 1); // Mechanism to log errors break; default: exit('The application environment is not set correctly.'); } } 
deleted 70 characters in body
Source Link

I would usually go with the following code in my plain PHP project which are very smallprojects. If the project grows large then I will recommend:

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

I would usually go with the following code in my plain PHP project which are very small. If the project grows large then I will recommend:

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

I would usually go with the following code in my plain PHP projects.

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 
Active reading [<http://en.wikipedia.org/wiki/PHP>]. Removed meta information (this belongs in comments).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

I would usually go with the following code in my plain phpPHP project which are very small, if. If the project grows large then I will recommend.:

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url  =  null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url  =  'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break;   case 'PRODUCTION': $base_url  =  'Prod'Production url';URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

Hope this helps.

I would usually go with the following code in my plain php project which are very small, if the project grows large then I will recommend.

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT','DEVELOPMENT'); } $base_url  =  null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url  =  'http://localhost/product/'; ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL|E_STRICT); break;   case 'PRODUCTION': $base_url  =  'Prod url'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 

Hope this helps.

I would usually go with the following code in my plain PHP project which are very small. If the project grows large then I will recommend:

if(!defined('ENVIRONMENT')){ define('ENVIRONMENT', 'DEVELOPMENT'); } $base_url = null; if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'DEVELOPMENT': $base_url = 'http://localhost/product/'; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL|E_STRICT); break; case 'PRODUCTION': $base_url = 'Production URL'; /* https://google.com */ error_reporting(0); /* Mechanism to log errors */ break; default: exit('The application environment is not set correctly.'); } } 
Source Link
Loading