Debugging

Debug Class

In MV there is a class "Debug" containing some methods for debugging the scripts. The "pre()" method displays a dump of variable. With its help it is convenient to view the content of arrays and objects. The "echo" function is not required for this.

Debug :: pre($var);
Debug :: pre($mv -> pages);

Generation time and count of SQL queries

There is a parameter in "index.php" file that makes it possible to see generation time, number of called queries, and also the included template file. For this you need to pass 1 (by default, 0) as a parameter when creating "$debug" object. After page reload you can see the list of information about this page in the end.

<?
require_once "config/autoload.php";
$debug = new Debug(1);
...
?>

Detection of Browser type

The browser of the user can be detected by a static browser() method of the class "Debug". Returns a browser type, possible value are "firefox", "ie", "opera", "chrome", "safari" or "false" if not in the list of the types.

$browser = Debug :: browser();

if($browser == "ie")
{
   ...
}

Detection of Mobile device

The following mobile devices can be detected: Android, iPhone, iPod, BlackBerry, IEMobile, Windows Phone. Return values are: "android", "iphone", "ipod", "blackberry", "ie", "windows" or "false" if not in the list of these types.

if(Debug :: isMobile() == "android") 
    include ...;

if(Debug :: isMobile()) 
{ 
    ... 
}

Detection of Tablet device

The following tablet devices can be detected: Android, iPad, Windows. Return values are: "android", "ipad", "windows" or "false" if not in the list of these types.

if(Debug :: isTablet() == "ipad")
    include ...;