By now, the Node.js server is running and routing HTTP requests to
the correct handler function, the
function, in the correct Node.js local module for that page request. The
local modules contain a simple framework based on the
exports.serve() function that is correct Node.js
code but the
page() function itself
mostly contains PHP code with a few Node.js modifications mixed in. When a
client requests a page, the Node.js server probably stops with a stack
The good news is that the Node.js server infrastructure is done. From here on out, all our conversion efforts are focused on making transformations to the hybrid PHP/Node.js code that constitutes the page itself.
Initially, the hybrid code will be mostly PHP with a little bit of Node.js, but as the conversion techniques from this chapter and the remaining chapters are applied, the balance in hybrid code will shift from being mostly PHP to being a balance of PHP and Node.js, then being mostly Node.js with a little bit of PHP, and finally, being fully working pure Node.js code.
In this chapter, we will deal with syntax, the “standard parts” of
a language. The syntax of a language consists of the keywords and symbols
used to create different statements. For example, in Node.js and every other computer language ever
invented, the plus (+) operator is the syntax used to add two numbers
together; in the code fragment
4+5, the plus (+) operator is a piece of syntax. In contrast, the semantics of a language ...