PHP alternative for NodeJS?

I come from a PHP background, but decide to try NodeJS (and probably Express) in my latest project. What is the PHP alternative for HTML page templates? I'm used to doing:

<?php include('header.php'); ?>

I tried a google search and browsed through Stack Overflow, but cannot find an alternative to NodeJS.

+4
source share
1 answer

If you want to load only exported objects from an external file, you can use the function require.

var imported = require('your-module');

If you want to execute an external Javascript file directly in your global scope (similar to PHP include), you should use eval.

eval(require('fs').readFileSync('your-module\\index.js') + '');
0

Source: https://habr.com/ru/post/1651915/


All Articles