PHP2CPP feature summary


This table summarizes the translation done by the version of PHP2CPP available with the March 2002 issue of Dr. Dobb's Journal. (The software is also available here.)
A feature is marked "Y" in "Support Lex" if the C++ output will be legal C++.

A feature is marked "Y", in "Support Oper" if the C++ output has the same functional meaning as the PHP. Remember the purpose of this release of the tool is lexical scan. An improved tool is in development.

'*' means see the text in the Dr. Dobb's March 2002 article for additional explanation, or Contact us.

PHP featureWhat PHP2CPP does Supported
Lex/Run
Implemented in
Function use before declarationSeparate pass to get declarationsY/Ymain()
Statements outside function bodiesSeparate pass to create a main()Y/Ymain()
ClassesSeparate pass to write class declarationsY/Ymain()
Standard escaping from HTML <?php ?>calls to showhtml() Y/YProcessFile()
Alternative escaping from HTML<? ?> <% %> <script>Not supported in this versionN/N ()
3 styles of comments/* */, //, and #/* */ or // The entire comment is recognized so that nothing inside is translated Y/Ytranscomment()
String concatenation operator (.)'+' overload to a string class Y/YtransDot()
Single quoted stringsTranslates to " " Y/YtransSquote()
Double quoted strings, which interpret $variablesSplit into constant "" with + operator Y/YtransDquote()
Strings can cross line boundariesTranslator issues warningY/YtransDquote()
$VariablesReplacement of '$' with _s_Y/YtransVar()
Variable variables ($$)Not supportedN/N ()
Case sensitive variable namesSupported (No translation needed.)Y/Y ()
Declare global variables inside function bodiesLexical translation. Y */Ntransglobal()
Array subscripts[ ]Translation of bare words to strings. PHP subscript must not cross line boundary Y/YtransSubscript()
Member of class access->Translates to '.' Y/YtransMember()
echo, print parameter without ( )Enclose parameter in ( ) Y/YtransReserved()
if() while() tests of strings and arraysEnclose conditional expression in !!( ) which allows a ! operator overload to work. Y */YtransReserved()
elseifTranslate to 'else if' Y/YtransReserved()
low precedence operators 'or' , 'and'Translate to ||, && (Wrong for precedence and when calling void() functions as the right hand parameter. )Y/NtransReserved()
low precedence operator 'xor'Not supportedN/N ()
require, includeSupportedY/YtransReserved()
Remote URLs for require, includeNot supported in this versionN/N ()
@ (per-call error message suppression)Replace with /*@*/ Y/NtransAT()
Type juggling, undeclared variablesStrong typing with some automatic conversions*/* ()
Backticks system calls (``)Not supported in this versionN/N ()
Deprecated syntax for control structures(:, endif, endswitch)Not supported. Use the regular syntaxN/N ()
===,!== (PHP4 only)Not supported in this versionN/N ()
foreach (PHP4 only)Not supported in this versionN/N ()
HEREDOC strings (PHP4 only)Not supported in this versionN/N ()
Case insensitive function namesNot translated*/* ()
Local functionsSupported (No translation.)*/* ()
Variable functionsNot supportedN/N ()

Copyright 2002, Forrest J. Cavalier III
Mib Software
High Reuse Software Development