RE: New Help with Javascript Navigation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sounds like you may be a young dude ;-)  You know what they say about us old
dogs and new tricks.  

PHP was a wonderful new trick for me, but javascript still stretches me a
bit much, and if it weren't for the similarities you mention, I'd be
completely lost.  I think the reason we keep getting questions about
Javascript on this list, is because others are struggling with it as I am.
It would be nice if it were covered by PHP.

Just think how it would be if you could write PHP that could access the
browser object model and alter settings on the clients screen dynamically,
of course, at some stage it would be necessary to implement a means of
communicating back to the server, but just to be able to provide interaction
on the client machine would be a great start.

Warren Vail

-----Original Message-----
From: paul@xxxxxxxxxxxxxxxxxxx [mailto:paul@xxxxxxxxxxxxxxxxxxx] 
Sent: Wednesday, April 26, 2006 2:37 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  New Help with Javascript Navigation

At 01:36 PM 4/26/2006, Warren Vail wrote:
"PHP appears to me to be incomplete unless it can provide a way to provide
client (browser) side executables in a consistent language, namely PHP.
Developers get all excited about the elegence of the PHP language, and
somewhere along the way they discover they have been sandbagged (they have
to learn Javascipt too, if they want responsive GUI's).

"One solution would be to develop a PHP Plugin and support that for all the
browsers out there, but another just occurred to me.  What if there was a
function that accepted PHP code as input and tranlated it to Javascript,
returning the resulting text ready for imbedding in html?"


Nice idea, although "sandbagged" sounds like an exageration: becoming fluent
in both PHP & JavaScript is hardly a major life challenge.  When I finally
learned PHP I was delighted at how syntactically similar it was to
JavaScript, compared say to the difference between JavaScript & VBscript. 
Perhaps my most common mistake in writing in both PH & JS is that I tend to
use . as a concatenation operator in JavaScript these days...


At 02:16 PM 4/26/2006, Evan Priestley wrote:
"No, I'm saying that Javascript can't read or write files on the client's
machine, and that this is only one of a large number of basic limitations in
the language's capabilities. It would be possible to write a script which
took "$a = 3" and converted it into "var a = 3", but a huge number of PHP
functions either can't be implemented in Javascript (file_get_contents) or
are fundamentally unsafe to implement in Javascript (mysql_query), so you'd
end up with a language you couldn't do anything with."

To the contrary, client-side PHP would simply be a different environment
from server-side PHP -- of course certain functions wouldn't apply and
others would that aren't relevant to server-side PHP, but that's not rocket
science.  The point would be to use the same syntax in both contexts.


Relevant to this discussion, there is a set of PHP DOM functions (native to
the core) that look like they match with the corresponding JavaScript
functions pretty closely:
http://php.net/dom
I haven't used them yet, but the function names look familiar.

The way I might implement such a PHP->JavaScript translation might look like
this:

<script type="text/javascript"
src="phpToJavaScript.php?src=myscript.php"></script>

where phpToJavaScript.php is the translation program and myscript.php is the
"client-side PHP" script to be translated to JavaScript.

Paul

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux