/    Sign up×
Community /Pin to ProfileBookmark

variables with Javascript and PHP

Can I share variables between Javascript and PHP?
like for say that in Javascript:

[CODE]<script language=”javascript”>
$var1 = bob;
</script>[/CODE]

and then using the same variable with the same value in PHP:

[CODE]<?php
echo (‘Hello ‘).$var1;
?>[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 26.2005 — PHP to Javascript is easy. Just have PHP echo the javascript as you want. Javascript to PHP is another matter entirely. Only way I can think of is to GET or POST it to a script via a form.

Oh by the way, you might wanna use <script type="text/javascritpt"> rather than <script language="javascript">
Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 26.2005 — Oh but the way, you might wanna use <script type="text/javascritpt"> rather than <script language="javascript">
Copy linkTweet thisAlerts:
@cobrasniper555authorAug 26.2005 — ya, ok, thanks
×

Success!

Help @cobrasniper555 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...