I'm trying since a lot of time, passing simple variables from php to JS.
I can find very often the following code.
- Code: Select all
<html>
<head>
<?php
$size = GetImageSize("http://www.fiftiesweb.com/elvis-portrait2sm.jpg");
$pictureWidth=$size[0];
?>
<script language="JavaScript">
var pictureWidth = <?= $pictureWidth ?>; // or
var pictureWidth = <?PHP echo $pictureWidth; ?>; // or
var pictureWidth ="<?PHP echo $pictureWidth; ?>";
document.write(pictureWidth);
alert(pictureWidth);
</script>
</head>
<body>
</body>
</html>
but it always shows an error in Javascript and a blanc window.
I tried this on two different php-servers. But I can't get it work.
What is the detail that I forgot ?
Or is it better with a $_GET or $_POST and hidden forms?
If so, does somebody know a simple working example to learn how to do.
I was hardly trying since three weeks to find something of these possibilitys.
No complete basic examples to find !!
Thanks in advance to all of you for your experience !!
Kar


