NYCPHP Meetup

NYPHP.org

[nycphp-talk] translating behaviors from JavaScript to PHP

-sry sryBoston at hotmail.com
Wed Dec 3 07:43:11 EST 2003


On Tuesday, December 02, 2003 12:36 PM
"Hans Zaunere" <hans not junk at nyphp.com>
> -sry wrote:
> > [ repost - sent to the wrong list ]
> > [snip]
> >>vis my personal web site. Since I like to keep code as 
> >>modularized as possible, I separated out my JavaScript 
> >>(for mouseover behavior and other sillyness) into a .js file.  
> >>As a mechanism for putting my hands on some PHP as I 
> >>learn it, I figured I'd take the existing page design and 
> >>behavior and "translate" it into a PHP implementation.
> 
> Keep in mind that PHP runs strictly on the server - the 
> browser is never aware of any PHP code.  Granted, you 
> can use PHP to generate the client-side code the browser
> then reads and parses, but translating between Javascript
> and PHP - in a linear sense - is not possible.

I guess my subject line wording is a bit misleading. I don't
mean a LITERAL translation. I meant to say I am trying
to translate my thinking into how to design the same
results/behavior with a different approach, a PHP approach.
There is always more than one way to skin any cat and I
am not used to thinking in PHP terms--as is apparent from
my newbie post where I was embedding HTML in PHP
rather than PHP into HTML which seems obvious now
that some of you have pointed it out to me :-) Thanks for 
the tips, guys.

I'm asking for more "tips" like this, how to approach, in
PHP, doing things like overwriting DIVs to dynamically
load content or how to replace stylesheets based on
user prefs using PHP rather than JS...such as the JS
code described at:

http://www.alistapart.com/articles/alternate/

Maybe some of these behaviors are simply not appropriate 
for a PHP implementation - I dunno - that's why I'm asking 
for your opinions :)

Maybe it'd better to ask, how would I go about "retooling" 
existing functionality from JS to PHP? Assuming the 
functionality is *not* specifically better-suited for a client-side 
scripting. Better way to ask? :)

-sry



More information about the talk mailing list