PHP code example of dennykuo / data-to-js

1. Go to this page and download the library: Download dennykuo/data-to-js library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dennykuo / data-to-js example snippets




use DataToJs\DataToJs;

...

$js = (new DataToJs)->put(['foo' => 'bar']);

(or)

$data = new stdClass();
$data->first = 'Peng';
$data->last  = 'Jie';

$js = (new DataToJs)->put(['foo' => 'bar', 'name' => $data]);


<script>
   $js->output();