HTML_Javascript
[ class tree: HTML_Javascript ] [ index: HTML_Javascript ] [ all elements ]

Class: HTML_Javascript_Convert

Source Location: /HTML_Javascript-1.1.2/Javascript/Convert.php

Class Overview


PHP to Javascript conversion classes


Methods


Inherited Variables

Inherited Methods


Class Details

[line 65]
PHP to Javascript conversion classes

It converts Variable or value to Javascript.



[ Top ]


Method Detail

convertArray   [line 261]

mixed convertArray( string $arr, string $varname, [boolean $global = false], [int $level = 0])

Converts a PHP array into a JS array supports of multu-dimensional array.

Keeps keys as they are (associative arrays).

  • Return: a PEAR_Error if no script was started or the converted array
  • Access: public

Parameters:

string   $arr   —  the array to convert
string   $varname   —  the variable name to declare
boolean   $global   —  if true, the JS var will be global
int   $level   —  Not public, used for recursive calls

[ Top ]

convertArrayToProperties   [line 326]

mixed convertArrayToProperties( $array, string $varname, [ $global = false], [boolean $new = true], string $arr)

Converts a PHP array into a JS object supports of multu-dimensional array.

Keeps keys as they are (associative arrays).

  • Return: a PEAR_Error or the converted array
  • Access: public

Parameters:

string   $arr   —  the array to convert
string   $varname   —  the variable name to declare
boolean   $new   —  if true, the JS var will be set
   $array   — 
   $global   — 

[ Top ]

convertBoolean   [line 213]

string convertBoolean( boolean $bool, string $varname, [boolean $global = false])

Converts a PHP boolean variable into a JS boolean variable.

Note this function does not check the type of $bool, only if the expression $bool is true or false.

  • Return: the value as javascript
  • Access: public

Parameters:

boolean   $bool   —  the boolean variable
string   $varname   —  the variable name to declare
boolean   $global   —  set to true to make the JS variable global

[ Top ]

convertNull   [line 235]

string convertNull( string $varname, [boolean $global = false])

Converts a PHP null variable into a JS null value.
  • Return: the value as javascript
  • Access: public

Parameters:

string   $varname   —  the variable name to declare
boolean   $global   —  set to true to make the JS variable global

[ Top ]

convertString   [line 188]

mixed convertString( string $str, string $varname, [boolean $global = false])

Converts a PHP string into a JS string
  • Return: a PEAR_Error if no script was started or the converted string
  • Access: public

Parameters:

string   $str   —  the string to convert
string   $varname   —  the variable name to declare
boolean   $global   —  if true, the JS var will be global

[ Top ]

convertValue   [line 363]

mixed convertValue( $val, string $param)

Converts a variable value to its javascript equivalent.

String variables are escaped (see escapeString()).

  • Return: return
  • Access: public

Parameters:

string   $param   —  coment
   $val   — 

[ Top ]

convertVar   [line 108]

mixed convertVar( mixed $var, string $varname, [boolean $global = false])

Converts a PHP variable into a JS variable you can safely provide strings, arrays or booleans as arguments for this function
  • Return: a PEAR_Error if no script was started or the converted variable
  • Access: public

Parameters:

mixed   $var   —  the variable to convert
string   $varname   —  the variable name to declare
boolean   $global   —  if true, the JS var will be global

[ Top ]

escapeString   [line 79]

mixed escapeString( string $str)

Used to terminate escape characters in strings, as javascript doesn't allow them
  • Return: the processed string
  • Source:
  • Access: public

Parameters:

string   $str   —  the string to be processed

[ Top ]

raiseError   [line 159]

mixed raiseError( integer $code, [ $str = ''])

A custom error handler
  • Return: false if the error code is invalid, or a PEAR_Error otherwise
  • Access: public

Parameters:

integer   $code   —  the error code
   $str   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:34:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.