PHP without dollar signs :)
Posted: Thu Jul 20, 2017 11:20 am
Hi,
I've just released an open-source tool (Phoenix) which allows to program PHP code with a more concise syntax.
Most of the PHP syntax has been kept unchanged, except for a few "tweaks" :
- dollar signs and 'this' are now implicit (i.e. not needed);
- '..' is used to concatenate strings, and '.' to access class members;
- the foreach loop syntax is 'foreach ( value; array )';
- '<? ... ?>' blocks contain Phoenix statements;
- '<% ... %>' blocks contain expressions to echo;
- '<# ... #>' blocks contain escaped expressions to echo.
- etc...
The main drawback is that you have to declare your local variables, and put your code in files with the '.phx' extension instead of '.php'.
I know that this tool has absolutely zero interest for those who like PHP's current syntax as it is, but unfortunately for me I wasn't one of them...
https://github.com/senselogic/PHOENIX
I've just released an open-source tool (Phoenix) which allows to program PHP code with a more concise syntax.
Most of the PHP syntax has been kept unchanged, except for a few "tweaks" :
- dollar signs and 'this' are now implicit (i.e. not needed);
- '..' is used to concatenate strings, and '.' to access class members;
- the foreach loop syntax is 'foreach ( value; array )';
- '<? ... ?>' blocks contain Phoenix statements;
- '<% ... %>' blocks contain expressions to echo;
- '<# ... #>' blocks contain escaped expressions to echo.
- etc...
The main drawback is that you have to declare your local variables, and put your code in files with the '.phx' extension instead of '.php'.
I know that this tool has absolutely zero interest for those who like PHP's current syntax as it is, but unfortunately for me I wasn't one of them...
https://github.com/senselogic/PHOENIX
Code: Select all
function GetMessage(
string first_name,
string last_name
)
{
global
hello;
local
message;
message = hello .. " " .. first_name .. " " .. last_name .. " !";
return message;
}
class HOBBIT
{
attribute
FirstName = "",
LastName = "",
RingCount = 0;
static attribute
HobbitCount = 0;
method constructor(
string first_name,
string last_name,
int ring_count
)
{
.FirstName = first_name;
.LastName = last_name;
.RingCount = ring_count;
self::AddHobbit();
}
method destructor()
{
.RemoveRings( .RingCount );
self::RemoveHobbit();
}
}
<ul>
<? foreach ( var dwarf_name; dwarf_name_array ) { ?>
<li>
<% dwarf_name %>
</li>
<? } ?>
</ul>