I want to execute a javascript function from a php file
Like:
<?php
$type=0;
echo('<img onclick="alert('.$type.')" src="picture.jpg"/>');
?>
Result : ok everything is workin. Now i want to do it with a string:
<?php
$type='e';
echo('<img onclick="alert('.$type.')" src="picture.jpg"/>');
?>
Result : Uncaught ReferenceError: e is not definedonclick @ loadPlayer2.php:2
<?php
$type='e';
echo('<img onclick="alert("'.$type.'")" src="picture.jpg"/>');
?>
Result : Uncaught SyntaxError: Unexpected token }
<?php
$type='e';
echo('<img onclick="alert(\"'.$type.'\")" src="picture.jpg"/>');
?>
Result : Uncaught SyntaxError: Unexpected token ILLEGAL
<?php
$type='\e';
echo('<img onclick="alert("$type")" src="picture.jpg"/>');
?>
Result : Uncaught SyntaxError: Unexpected token }