Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character that could replace the semi colon!

Status
Not open for further replies.

vincelewin

IS-IT--Management
May 16, 2002
83
GB
Any one know how I can incorporate javascript into a php page, considering that php see's a semi colon as the end of the line and returns down to begin the next line as soon as it see this.

Im pretty sure that you cannot omit or replace this in php and other than ending the php just before typing the javascript and starting it again afterwards, I cannot think of how I can do this.

If there is an alternate character that can be used in the javascript then it can be incorporated directly into php.

I appreciate this is part php and part javascript question and wont be upset if I cant resolve it but am curios to see if anyone can shed any light.

Vince
 
Maybe a quick example will show you how you can combine " and ' to good effect in the case of the semi-colon.
Code:
<?
$html = "\n".'<script type="text/javascript">';
$html .= "\n".'var myString = "Hello world";';
$html .= "\n".'alert(myString);';
$html .= "\n</script>";

echo $html;
?>
Ought to generate the following code when viewed using client-side view-source:
Code:
<script type="text/javascript">
var myString = "Hello world";
alert(myString);
</script>
Hope that gives you some ideas,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top