枕边书

枕边书

常怀敬畏之心。

  • 财富值60
  • 威望值0
  • 总积分100

个人信息

  • 赞了回答
    1. 首先html或者js中的<?php ... ?>以及<?= ... ?>都是在后端执行的(通过webserver调用php程序对.php文件解析执行),而js是前端脚本,由浏览器解释执行的。

    2. js'调用'的php对象,在后端就定格了,不会再变化。php脚本变成了html或者js。

    3. 你的php中想要使用js对象,只能用<?php ... ?>和js混写,而不适合用<?= ... ?>方法。js对象(比如你的问题中的data)不能嵌在在<?php ?>内。

    例如这样混写:

        var val = '';
    	<?php $i=0; foreach ($un_grouped_boxes as $k => $v) { $boxid = $v['id'];  ?>
    	    var box = getObjInBoxes(<?= $boxid ?>);
    	    console.log('mac:'+box['lan_mac']);
    	    val += '<li class="ads-group-boxes-info" >';
    	    val += '    <div style="width:100%;">';
    	    val +=
    		    '<?php
    			echo "<span >";
    			$itmp = ($i==0)?'fa fa-circle':'fa fa-circle-o';
    			$icon = '<span boxid="'.$boxid.'" id="boxid-'. $boxid. '" class="'
    			    . $itmp . '">&nbsp;</span>';
    			echo Html::a($icon.$v["lan_mac"], "javascript:void(0)",[
    			    "onclick" => "selectBox($boxid)",
    			    "style" => "text-decoration:none;",
    			]);
    			echo "</span>";
    		    ?>';
    	    val += '</div>';
    	    val += '    <div class="ads-group-boxes-info-bottom" style="font-size:10px;">';
    	    val += '       &nbsp;&nbsp;&nbsp;&nbsp;<span>序列号:<?= $v["sn"] ?> </span>';
    	    val += '    </div>';
    	    val += '    </li>';
    	    <?php 
    		if ($i==0){
    	    ?>
    		var v = <?= json_encode($v) ?>;
    		show_box_info(v);
    	    <?php } ?>
    	<?php $i++;} ?>
        if (val != ''){
    	val = '<ul class="list-unstyled">'+val+'</ul>';
        }
        _list.html(val);
    
  • 发表了说说
    昨天断签了。。。
  • 2015-12-30 已签到
    连续签到1天,获得了5个金钱
  • 赞了教程
    Yii2.0 场景的简单使用
  • 回复了 的回答

    貌似User中的规则rules里的验证码部分要指定下action位置,因为我看你是在modules用的,如:

    ['verifyCode', 'captcha', 'captchaAction'=>'admin/default/captcha', 'on' => 'login'], //验证码
    

    请问为什么我的配置好之后点击切换了图片之后,session里的验证码没有切换,导致点击切换图片之后一直验证错误。。。

  • 回复了 的回答

    这个很简单,你按着我的配置来即可。

    server {
            charset utf-8;
            client_max_body_size 128M;
            listen          80;
            server_name     local.yii2test.com
            index           index.php index.html index.htm;
            root            /usr/local/nginx/html/yii2test/web;
    
            location ~ \.php$ {
                root           /usr/local/nginx/html/yii2test/web;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi_params;
            }
            #yii框架使用代码
            location / {
                # Redirect everything that isn't a real file to index.php
                try_files $uri $uri/ /index.php?$args;
            }
    
            location ~ /\.ht {
                    deny  all;
            }
        }
    

    上面我给你做了一个虚拟域名,你按着我的配置就可以正常访问了。 url 最终是这样的 local.yii2test.com/index

    大神,我用的apache,怎么能把url中的web路径弄掉呢,我用apache重写弄掉了,但是使用Url::to()方法产生的url还是带有web。。。

  • 回复了 的回答

    在 web 目录下添加 .htaccess

    Options +FollowSymlinks
    IndexIgnore */*
    RewriteEngine On
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . index.php
    

    你好,你是怎么使地址直接指向web目录下的呢?

  • 2015-12-28 已签到
    连续签到6天,获得了20个金钱
  • 赞了教程
    Yii 2.0 批量插入数据
  • 6666,赞一个!!!

助理 等级规则
100/200
资料完整度
70/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

0

Ta的访客

3