PHP Developers Network
http://forums.devnetwork.net/

PHP without dollar signs :)
http://forums.devnetwork.net/viewtopic.php?f=6&t=143977
Page 1 of 1

Author:  ecstatic.coder [ Thu Jul 20, 2017 11:20 am ]
Post subject:  PHP without dollar signs :)

Hi,

I've just released an open-source tool () 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

Syntax: [ Download ] [ Hide ]
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>
 

Author:  requinix [ Thu Jul 20, 2017 11:59 am ]
Post subject:  Re: PHP without dollar signs :)

So basically it's not PHP.

Author:  Christopher [ Thu Jul 20, 2017 2:18 pm ]
Post subject:  Re: PHP without dollar signs :)


Author:  ecstatic.coder [ Thu Jul 20, 2017 2:53 pm ]
Post subject:  Re: PHP without dollar signs :)


Author:  ecstatic.coder [ Thu Jul 20, 2017 3:06 pm ]
Post subject:  Re: PHP without dollar signs :)


Author:  Christopher [ Mon Jul 24, 2017 1:49 pm ]
Post subject:  Re: PHP without dollar signs :)

Had you started with PHP (or Perl), you'd be struggling with Javascript. And honestly, of the strange languages in the world, Javascript is pretty weird. It is prototype based and there are a bunch of different ways to make objects. It you learned it first, you have a strange perspective on languages. But Javascript is event driven, DOM traversing fun!

Author:  ecstatic.coder [ Mon Jul 24, 2017 2:44 pm ]
Post subject:  Re: PHP without dollar signs :)

Being able to add properties to a class instance (like in JS and PHP) is indeed a fantastic feature, and I regularly miss it when using strongly-typed languages.

I think that if I had learned JS after PHP, I probably would have still preferred the leaner JS syntax, but that doesn't mean I would prefer to use JS over PHP for web development.

I've already used Node.js in the past, and obvioulsy PHP is way easier to use, even compared to Go, Dart, etc.

Rename index.html to index.php, add a few lines of PHP code inside dedicated tags, and you have your first web server up and running. Nothing can beat this approach in ease of use.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/