PHP code example of moon / utilities-javascript

1. Go to this page and download the library: Download moon/utilities-javascript 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/ */

    

moon / utilities-javascript example snippets


use Moon\Utilities\Javascript\PHPToJavaScriptTransformer;

$transformer = new PHPToJavaScriptTransformer;

// example 1
$javascript = $transformer->set('name', 'moon')
			->set('age', 999999)
            ->transform()

// example 2
$javascript = $transformer->transform([
	'name' => 'moon',
    'age' => 999999
]);

// in your view

<script><?=$javascript