PHP Classes

File: test_javascript_string_escaping.php

Recommend this page to a friend!
  Classes of Manuel Lemos   PHP Forms Class with HTML Generator and JavaScript Validation   test_javascript_string_escaping.php   Download  
File: test_javascript_string_escaping.php
Role: Unit test script
Content type: text/plain
Description: Test script to verify the generation of escaped Javascript strings
Class: PHP Forms Class with HTML Generator and JavaScript Validation
HTML forms generation and validation.
Author: By
Last change:
Date: 16 years ago
Size: 472 bytes
 

Contents

Class file image Download
<?php

/*
 * test_javascript_string_escaping.php
 *
 * @(#) $Id: test_javascript_string_escaping.php,v 1.1 2008/02/04 05:58:20 mlemos Exp $
 *
 */

   
require('forms.php');

   
$form = new form_class;
   
$strings = array(
       
'',
       
"\n",
       
"\r",
       
"\t",
       
'<',
       
'%',
       
'\'',
       
'\\',
       
chr(160),
       
"\n<",
       
"<%",
       
"<'",
       
"<\\",
       
"<\n",
       
"<\r",
       
"<\t",
       
' <',
    );
   
$t = count($strings);
    for(
$s = 0; $s < $t; ++$s)
        echo
$form->EncodeJavascriptString($strings[$s]), "\n";
?>