script中如何做才能调用 php中的变量,如下所示

WBOY
Release: 2016-06-13 13:45:41
Original
704 people have browsed it

script中怎么做才能调用 php中的变量,如下所示:
script中怎么做才能调用 php中的变量,如下所示:

  $strbbb = 'www.163.com';
?>

<script><br />function(){window.location.href="$strbbb";}<br /></script>

本来可以在到163网站的,但是我网址却是 $strbbb , 这个该怎么改? 我不是计算机专业的,对这个不大懂,请高手指教

------解决方案--------------------
没法调用!一个客户端一个服务器端!

但可以
$strbbb = 'www.163.com'; 

echo "<script> <br />function(){window.location.href=\"".$strbbb ."\";} <br /></script> ";

?> 
不知道这个算不算!


------解决方案--------------------
$strbbb = 'www.163.com';
?>

<script><br />var aa="<? echo $strbbb; ?>"; <br />alert(aa); <br /></script>
------解决方案--------------------
$strbbb = 'www.163.com';
?>

<script><br />function(){window.location.href="<? echo $strbbb; ?> ";} <br /></script>
------解决方案--------------------

PHP code
<?php $strbbb   =   'www.163.com'; ?>
<br><font color="#e78608">------解决方案--------------------</font><br>不知道上面几位的代码都测试过没有!<br>抛开其他的单纯就<br>
Copy after login
JScript code

<script> 
var a = function(){window.location.href="www.163.com";}
 a();
</script>
<br><font color="#e78608">------解决方案--------------------</font><br><?php   <br />   $strbbb   =   'www.163.com';  <br>?>  <br><br><script>  <br />function(){window.location.href="<?=$strbbb?>";}  <br /></script>  <br>
<br><font color="#e78608">------解决方案--------------------</font><br><?php <br />   $strbbb   =   'www.163.com';<br>?><br><br><script><br />window.onload = function(){window.location.href="<?=$strbbb?>";}<br /></script>
<br><font color="#e78608">------解决方案--------------------</font><br>少了【http://】就跳转到你当前网站的目录【www.163.com】,应修改如下:<br><?php <br />   $strbbb = 'http://www.163.com';<br>?><br><br><script><br />window.onload   =   function(){window.location.href=" <?=$strbbb?> ";}<br /></script>
<br><font color="#e78608">------解决方案--------------------</font><br>不能如此处理<br>var   location   =   ' <?php print   $strbbb?> ';  <br>if   (location.indexOf('://')===-1){  <br>       location   =   'http://'+location;  <br>}  <br>这样根本不会跳转。<br>改<br><script>  <br />function func(){<br /> window.location.href = '<?php echo $strbbb; ?>';<br />}  <br />func();<br /></script><br>你要想纠正$strbbb可以在<br><?php   <br />$strbbb   =   'http://www.163.com';//也可以是www.163.com  <br>?>  <br>里就进行,何必要用javascript呢?
<br><font color="#e78608">------解决方案--------------------</font><br><?php $str="asdfa";?><br><script><br />var str="<?php echo $str;?>";<br /></script> <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!