Login   Register  
PHP Classes
elePHPant
Icontem

File: jsFlush-example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Malte Dreyer  >  jsFlush  >  jsFlush-example.php  >  Download  
File: jsFlush-example.php
Role: Example script
Content type: text/plain
Description: Examples for the jsFlush-class
Class: jsFlush
Output JavaScript and show PHP errors on the pages
Author: By
Last change: Changed listing priority
Date: 2 years ago
Size: 1,282 bytes
 

Contents

Class file image Download
<?php
    
/**
     * @package jsFlush
     */
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
        <?php
            
require_once('js.class.php');

            
$js = new jsFlush();

            
// test standard exec
            
$js->_js_exec('document.title = "Example: jsFlush";');

            
// set error handlers so that all E_USER_ types of errors will only be shown in the console
            
$js->_php_set_error_handler();

            
// trigger different types of errors
            
trigger_error('notice'E_USER_NOTICE);
            
trigger_error('warning'E_USER_WARNING);
            
// if set to true, the script execution stops at that point (through the use of exit)
            
$js->error_abort false;
            
trigger_error('error'E_USER_ERROR);

            
// test a normal js function
            
$js->alert('"someTxt"');
            
// has to be false for variables, btw
            
$js->auto_add_quotes true;
            
// with auto_add_quotes set to true it's easier to write strings but JSON objects etc. will also end up as such.
            
$js->alert('someTxt');

            
// test exception handler
            
$js->_php_set_exception_handler();
            throw new 
Exception('message'9412);
            
// script execution stops after the exception. This is done automatically and I don't know whether it can be deactivated.
        
?>
    </body>
</html>