...

View Full Version : possible use php in javascript ?



zodehala
12-23-2007, 11:11 PM
E.G. we can use html in php like


<?php echo ' <!--HTML codes-->' ; ?>

is it possbile to use php in javascript ?


<script language="javascript">
function example(){
//php codes
}
</script>

Nightfire
12-24-2007, 12:06 AM
You can have php write things into the javascript, but you can't have javascript parse/execute php.

oesxyl
12-24-2007, 12:09 AM
<script language="javascript">
function example(){
//php codes
}
</script>

Add after posting: sorry I missunderstand the question!!!

yes is possible, php generate the page on the server after browser request but before the browser see what is in that page, :)

best regards

Jesuspwnt
12-24-2007, 12:57 AM
E.G. we can use html in php like


<?php echo ' <!--HTML codes-->' ; ?>

is it possbile to use php in javascript ?


<script language="javascript">
function example(){
//php codes
}
</script>

these two are totally different..
the first echo's html tags from a php script
the second uses javascript to try to execute php

thindrakhya
12-24-2007, 01:35 AM
It depends what u want ur script to do,

If we want to insert any data into sql or want to display then usually i use


window.location = ....php;

and then use redirection after sql query

If u want to change anything then use ajax

There is no direct way to do it but u can work around these things

zodehala
12-24-2007, 05:55 AM
It depends what u want ur script to do,

If we want to insert any data into sql or want to display then usually i use


window.location = ....php;

and then use redirection after sql query

If u want to change anything then use ajax

There is no direct way to do it but u can work around these things

for example define COOKIE or ragister in mySQL dB

SeeIT Solutions
12-24-2007, 08:00 AM
You can do it behind the scenes with AJAX. That way information gets sent to PHP and back without the user really knowing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum