View Full Version : how to

12-11-2005, 11:59 AM
how i can to define this code into a variable?

srand ((double) microtime( )*1000000);
$random_number = rand( );

where $random_number is a variable to call like this:


12-11-2005, 12:25 PM
I don't understand you. "Define this code into a variable?" You mean you want to create a function? And the way you use that variable - short of a here-document - is never going to work. You want:
<b><?php echo($random_number); ?></b>

12-12-2005, 03:09 AM
I need to create this code in a so called variable <module:randomnumber> for then to be able to integrate with javascript. regards


<SCRIPT>potherfunctions('http://www.google.com','<module:randomnumber>', '')</SCRIPT>

12-12-2005, 08:06 AM
<SCRIPT>ppreview('http://www.google.com','<?php echo($random_number); ?>')</SCRIPT>
<SCRIPT>potherfunctions('http://www.google.com','<?php echo($random_number); ?>', '')</SCRIPT>
PHP and Javascript work at very different levels to one another, and the only way to pass a variable from PHP to Javascript is to echo it straight into the Javascript code.