Converts PHP to JS. I have no idea why I created this, I have no idea what I'm gonna do with it, and if you try to use it I feel sorry for you.
Enjoy.
First the program evaluates the AST of the PHP file you pass to it. Then, the program traverses every children of the program, converting it to JS AST. Then, the program writes to the defined JS outfile.
It will currently skip over any (yet) unsupported syntax.
The program can parse simple variable declarations of the following types.
- string
- boolean
- number
- float
<?php
$x = 1337;
$y = "1337";
$z = false;
$zz = 0.5;
?>
The program wil output the following JS code:
var x = 1337;
var y = "1337";
var z = false;
var zz = 0.5;
The program can parse basic function calls.
Currently supported global functions:
- print_r
- var_dump
- abs
<?php
print_r("Hello");
abs(10);
?>
This will output
console.log("Hello");
Math.abs(10);
Every other function will return the same function.
<?php
some_other_func("test");
?>
some_other_func("test");