Skip to content

Instantly share code, notes, and snippets.

@monmon
Created October 23, 2013 06:11
Show Gist options
  • Save monmon/7113323 to your computer and use it in GitHub Desktop.
Save monmon/7113323 to your computer and use it in GitHub Desktop.
phpでclassがないのにnewした場合にはExceptionではなくFatal error
<?php
class Monmon {
}
try {
$class = 'Monmon2';
if (class_exists($class)) { // これがないと Fatal error: Class 'Monmon2'
$monmon2 = new $class();
}
} catch (Exception $e) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment