Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php If-else语句显示为两个字符串:_Php_Html_Asp.net - Fatal编程技术网

Php If-else语句显示为两个字符串:

Php If-else语句显示为两个字符串:,php,html,asp.net,Php,Html,Asp.net,编辑第三集-在其中我们发现我真的不是很聪明 错误警报的人,我不能使用php在我目前的设置。我要去碰壁一会儿。无论如何,谢谢你的帮助和建议 我正试图遵循教程,以便允许在我的响应网站上进行“移动/完全”切换。但是,用于显示选项的链接同时显示了这两个选项,而不是像它应该显示的那样显示“非此即彼”的情况 本教程使用了一点PHP,我还不知道,所以我不知道错误在哪里。我觉得这一切都很好,但以下代码: <div id="toggleView"> <?php if ( $fixedwidth

编辑第三集-在其中我们发现我真的不是很聪明

错误警报的人,我不能使用php在我目前的设置。我要去碰壁一会儿。无论如何,谢谢你的帮助和建议


我正试图遵循教程,以便允许在我的响应网站上进行“移动/完全”切换。但是,用于显示选项的链接同时显示了这两个选项,而不是像它应该显示的那样显示“非此即彼”的情况

本教程使用了一点PHP,我还不知道,所以我不知道错误在哪里。我觉得这一切都很好,但以下代码:

<div id="toggleView">
<?php if ( $fixedwidth == '1' ): ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=0">Switch to Mobile site</a>
<?php else: ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=1">Switch to Full site</a>
<?php endif; ?>
    </div>
所以,我基本上是从教程中复制粘贴了这个,试图在我的页面上获得这个功能,但我不知道它是否真的正确

编辑2-电动Boogaloo

以下是相关页面中的代码:

<%@ Master Language="c#" CodeFile="Standard.master.cs" Inherits="Standard_" %>
<%@ Register Src="/include/menu_left.ascx" TagName="menu_left" TagPrefix="uc4" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<?php
    $fixedwidth = '1';
    // Check if the query string contains our key and assign its value to $fixedwidth
    if ( isset($_GET['fixedwidth']) && ($_GET['fixedwidth'] != "") ) {
        $fixedwidth = $_GET['fixedwidth'];
    }
    // Check if a cookie has already been set
    if ( isset($_COOKIE['fixedwidth']) ) {
        if ( $fixedwidth == '0' ) {
            // If the value is '0', delete the cookie
            setcookie('fixedwidth', '', time() - 60, '/');
        } else {
            // Value is not '0', so no need to get the cookie value
            $fixedwidth = '1';
        }
    } else if ( $fixedwidth == '1') {
        // The user wants fixed width, so set a cookie
        $expires = 60 * 60 * 24 * 60 + time(); 
        setcookie('fixedwidth', '1', $expires, '/');
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Website Title</title>
    <asp:ContentPlaceHolder ID="MetaDescriptionHolder" runat="server" Visible="true">
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder ID="MetaKeywordsHolder" runat="server" Visible="true">
    </asp:ContentPlaceHolder>
    <meta name="author" content="website" />

<?php
// Only insert the meta[name="viewport"] element if responsive is not disabled
if ( $fixedwidth = '1' ): ?>
    <meta name="viewport" content="width=1400, initial-scale=1" />
<?php endif; ?>

    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" type="text/css" href="fontawesome/css/font-awesome.min.css">
    <link href="favicon.ico" rel="shortcut icon" />
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet' type='text/css'>
    <style type="text/css"><!-- @import url("../../../css/responsive.css?t=<%= DateTime.Now.Ticks %>"); --></style>
    <%--<style type="text/css"><!-- @import url("../../../css/main-cs.css?t=<%= DateTime.Now.Ticks %>"); --></style>--%>
    <script language="javascript" type="text/javascript" src="../../../js/jquery1.4.2.js"></script>
    <script language="javascript" type="text/javascript" src="../../../js/validation.js"></script>
    <script language="javascript" type="text/javascript" src="../../../js/functions.js"></script>
    <script language="javascript" type="text/javascript" src="/js/browser-selector.js"></script>

    <script src="/js/jquery.autocomplete.js" type="text/javascript"></script>
    <asp:ContentPlaceHolder ID="slideshowHolder" runat="server" Visible="true">
    </asp:ContentPlaceHolder>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=txtSearch.ClientID %>").autocomplete('/SearchTextBox.ashx');
        });       
    </script>
    <script type="text/javascript">
        function displayLogin(obj) {
            if (obj.checked) {
                if (!confirm('If you tick this box then you will no longer need to log in when visiting website from this computer.\n\nYou can disable this feature at any time by logging out.\n\nDon\'t use this option unless you are the only person who has access to this computer.\n\nWARNING:\nIf you do decide to use this option you will be liable for the actions of anyone who uses your login to access website.'))
                { obj.checked = false; }
            }
        }

        var mouse_is_inside = false;

        $(document).ready(function () {


            $('#login_box').hover(function () {
                mouse_is_inside = true;
            }, function () {
                mouse_is_inside = true;
            });



        });

</script>
</head>
<body>


    <form id="Form1" runat="server">
    <div class="top-menu">
        <div class="top-menu-holder">
            <div class="top-menu-tabs">
                <div class="top-menu-tabs-shop-on">
                    <a href="/"><strong>Online Store</strong></a>
                </div>
                <div class="top-menu-tabs-residential">
                        <a href="http://www. <strong>IT Services</strong></a>
                    </div>
                <div class="top-menu-tabs-services">
                    <a href="link">Business <strong>IT Services</strong></a>
                </div>
            </div>
                <div class="top-menu-menu">
                    <ul>
                        <li class="line"><a href="/contact-us.aspx" alt="Contact Us" title="Contact Us">Contact</a></li>
                        <li class="line"><a href="/about-us.aspx" alt="About Us" title="About Us">About</a></li>
                        <li class="line"><a href="/feedback.aspx" alt="Feedback" title="Feedback">Feedback</a></li>
                        <li class="line"><a href="/testimonials.aspx" alt="Testimonials" title="Testimonials">
                        Testimonials</a></li>
                        <li class="line"><a href="/employment.aspx" alt="Employment" title="Employment">Employment</a></li>
                        <li class="line"><a href="/awards.aspx" alt="Awards" title="Awards">Awards</a></li>
                        <li class="line"><a href="/Gift-Vouchers/Gift-Vouchers/Index.aspx" alt="Gift Vouchers" title="Gift Vouchers">Vouchers</a></li>
                        <li class="line"><a href="/promotions.aspx" alt="Promotions" title="Promotions">Promotions</a></li>
                    </ul>
                </div>
        </div>
    </div>
    <div class="page-content">
        <div class="shop-header">
            <div class="shop-header-logo">
                <a href="/">
                    <img alt="Online Store" src="/images/shop-logo.png" /></a>
            </div>
            <div class="shop-header-phone">
                Freephone<br />

            </div>
            <div class="shop-header-ad" style='<%# "display:" + (c.CustomerID >0 || Convert.ToInt32(c.GetTotalsForCart()[0]) > 0  ? "none": "") %>'>
                <a href="https://shop.eset.co.nz/shop/?mode=tr&resellerid=IyUqXygK">
                    <img alt="eset free 30 day trial" src="/images/top-strip-ad/eset-trial.jpg" title="eset free 30 day trial" /></a>
            </div>
            <asp:Panel ID="pnlCart" runat="server">
                <div class="shop-header-cart">
                    <div class="shop-header-cart-label-cart">
                        Shopping Cart:</div>
                    <div class="shop-header-cart-label-link">
                        <a id="A12" class="white" href="~/cart.aspx" runat="server">Shopping Cart:</a></div>
                    <div class="shop-header-cart-label">
                        Items:</div>
                    <div class="shop-header-cart-details">
                        <asp:Label ID="lblProducts" runat="server"></asp:Label></div>
                    <div class="shop-header-cart-label">
                        Total:</div>
                    <div class="shop-header-cart-details">
                        $<asp:Label ID="lblCost" runat="server"></asp:Label></div>
                    <div class="shop-header-cart-button">
                        <div class="green-button">
                            <a id="A6" href="~/cart.aspx" runat="server">View Cart</a>
                        </div>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="pnlAccount" runat="server" Visible="false">
                <div class="account-menu">
                    <ul>
                        <li><a id="A2" href="~/saved-carts.aspx" runat="server">Saved Carts</a></li>
                        <li id="lstAccountModule1" runat="server" visible="false" class="line"><a id="A3"
                            href="~/transactions.aspx" runat="server">Transactions</a></li>
                        <li id="lstAccountModule2" runat="server" visible="false" class="line"><a id="A4"
                            href="~/orders.aspx" runat="server">Orders</a></li>
                        <li id="lstServiceModule1" runat="server" visible="false" class="line"><a id="A5"
                            href="~/service-tickets.aspx" runat="server">Service Tickets</a></li>
                        <li id="lstManageModule" runat="server" visible="false" class="line"><a id="A7"
                            href="~/manage.aspx" runat="server">Manage</a></li>
                    </ul>
                </div>
            </asp:Panel>
        </div>

        <div class="shop-menu-login-bar">
                <asp:Panel ID="pnlLoggedOut" runat="server" autocomplete="off">
                    <ul>
                        <li>
                            <a href="/log-in.aspx" alt="Log In" title="Log In">Log In</a>                   
                        </li>
                        <li class="line">
                            <a href="/create-account.aspx" alt="Register" title="Register">Register</a>
                        </li>
                    </ul>

                </asp:Panel>
                <asp:Panel ID="pnlLoggedIn" runat="server" autocomplete="off">
                    <ul>
                        <li>
                            <a href="~/log-in.aspx?logout=1" id="A8" runat="server">Logout</a>                  
                        </li>
                        <li class="line">
                            <a id="A9" href="~/update-details.aspx" runat="server">My Details</a>
                        </li>
                    </ul>
                </asp:Panel>
                <asp:Panel ID="pnlsearch3" runat="server" DefaultButton="btnsearch3">
                    <div class="search-3">
                        <asp:TextBox ID="txtSearch3" runat="server" Class="search-textbox-3" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
                            onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
                            onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
                            MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnsearch3_Click" />
                        <asp:ImageButton ID="btnsearch3"  Class="search-icon-3" ImageAlign="Right" BackColor="White"  runat="server" Width="20" Height="20" OnClick="btnsearch3_Click" ImageUrl="~/images/search-icon.gif" />
                    </div>
                </asp:Panel>
            </div>

        <div class="shop-menu">
            <div class="shop-menu-float-left">
                <ul>
                <li><asp:HyperLink runat="server" ID="hlComputers" NavigateUrl="/Computers/Index.aspx" Text="Computers" ToolTip="View Products in Computers Category"/></li>
                    <li class="line"><asp:HyperLink ID="hlElectronics" NavigateUrl="/Electronics/Index.aspx" runat="server" tooltip="View Products in Electronics Category" Text="Electronics"/></li>
                    <li class="line"><asp:HyperLink ID="hlExLease" NavigateUrl="/Computers/Ex-Lease/index.aspx" runat="server"  tooltip="View our Ex-Lease Items" Text="Ex-Lease"/></li>
                    <li class="line"><asp:HyperLink ID="hlClearance" NavigateUrl="/search.aspx?S=Clearance+Item&picture=0" runat="server" tooltip="View our Clearence Items" Text="Clearance"/></li>
                    <li class="line"><asp:HyperLink ID="hlRepairs" NavigateUrl="/Christchurch-Computer-Repairs-and-Service.aspx" runat="server" tooltip="View our Store Service Department" Text="Repairs" /></li>
                </ul>
            </div>
            <div class="shop-menu-float-right">
                <asp:Panel ID="pnlLogin" runat="server" autocomplete="off">
                    <div class="green-button">
                        <a href="#" alt="Log In" title="Log In" onclick="$('#login_box').fadeIn(&#34;fast&#34;); mouse_is_inside = true; if(frmvalidator != null) { DisableAllValidators();}; return false;">Log In</a>
                    </div>
                    <div class="my-details">
                        <div class="green-button">
                            <a href="/create-account.aspx" alt="Register" title="Register">Register</a>
                        </div>
                    </div>
                    <div id="login_box">
                        <div id="login_box_content">
                            <div class="login-row">
                                <h2 class="login">
                                    Login<a onclick="javascript:$('#login_box').fadeOut(&#34;fast&#34;);"><img alt=''
                                        src="/images/close.png" class="login-close" /></a></h2>
                            </div>
                            <div class="login-row">
                                <div class="login-label">
                                    Email</div>
                                <div class="login-field">
                                    <input type="text" id="txtLoginEmail" autocomplete="off" name="txtLoginEmail" tabindex="1" maxlength="255"
                                        class="login-input" /></div>
                            </div>
                            <div class="login-row">
                                <div class="login-label">
                                    Password</div>
                                <div class="login-field">
                                    <input type="password" name="txtLoginPassword" autocomplete="off" id="txtLoginPassword" tabindex="2"
                                        maxlength="255" class="login-input" />
                                </div>
                            </div>
                            <div class="login-remember">
                                <div class="login-remember-field">
                                    <input name="auto_login" id="auto_login" onclick="displayLogin(this);" tabindex="3" type="checkbox" />
                                </div>
                                <div class="login-remember-label">
                                    Remember Me
                                </div>
                            </div>
                            <div class="login-button">
                                <div class="green-button">
                                    <input type="image" causesvalidation="false" src="/images/log-in.png" alt="login" title="login" tabindex="4" runat="server" id="login" />
                                </div>
                            </div>
                            <div class="login-remember">
                                <a href="/forgotten-password.aspx">Forgot your password?</a>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" name="previousPage" value="<%=strPreviousPage %>" />
                </asp:Panel>
                <asp:Panel ID="pnlLogoutMenu" runat="server">
                    <div class="green-button">
                        <a href="~/log-in.aspx?logout=1" id="logout" runat="server">Logout</a>
                    </div>
                    <div class="my-details">
                        <div class="green-button">
                            <a id="A1" href="~/update-details.aspx" runat="server">My Details</a>
                        </div>
                    </div>
                </asp:Panel>
            <asp:Panel ID="pnlSearch" runat="server" DefaultButton="ImageButton1">
                    <div class="search-textbox">
                                                <asp:TextBox ID="txtSearch" runat="server" CssClass="search" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
                            onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
                            onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
                            MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnSearch_Click" /><asp:ImageButton ID="ImageButton1"  Class="search-icon" ImageAlign="Right" Width="15" Height="15" BackColor="White"  runat="server" OnClick="btnSearch_Click" ImageUrl="~/images/search-icon.gif" />
                    </div>
                </asp:Panel>

            </div>



                    <input type="hidden" name="previousPage" value="<%=strPreviousPage %>" 
            </div>

            <asp:Panel ID="pnlmsearch" runat="server" DefaultButton="btnmsearch" Visible="true">
                    <div class="search-m">
                        <asp:TextBox ID="txtSearchM" runat="server" Class="search-textbox-m" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
                            onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
                            onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
                            MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnmsearch_Click" />
                        <asp:ImageButton ID="btnmsearch"  Class="search-icon-m" ImageAlign="Right" BackColor="White"  runat="server" Width="30" Height="30" OnClick="btnmsearch_Click" ImageUrl="~/images/search-icon.gif" />
                    </div>
                </asp:Panel>
        <div class="content-holder">
            <div class="page-content-menu">
                <uc4:menu_left ID="Menu_left" runat="server" />
            </div>
            <div class="page-content-info">
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
                            </div>
        </div>

        <div class="footer">
        <div id="toggleView">
<?php if ( $fixedwidth == '1' ) { ?>
    <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=0">Switch to Mobile site</a>
<?php } else { ?>
    <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=1">Switch to Full site</a>
<?php } ?>
</div>
            <div class="footer-content">
                <div class="footer-content-border">
                    <div class="footer-payment-method">
                            <div class="footer-payment-method-border">
                                <div class="footer-payment-text">
                                Secure online payments with <strong>3D Secure</strong></div>
                                <div class="footer-payment-visa-verified">
                                    <img runat="server" src="/images/verified-by-visa.png" alt="Verified by Visa" title="Verified by Visa" /></div>
                                    <div class="footer-payment-mastercard-securecode">
                                    <img runat="server" src="/images/mastercard-securecode.png" alt="MasterCard SecureCode" title="MasterCard SecureCode" /></div>
                                <div class="footer-payment-visa">
                                    <img runat="server" src="/images/visa-logo.png" alt="site accepts Visa" title=site accepts Visa" /></div>
                                <div class="footer-payment-mastercard">
                                    <img runat="server" src="/images/mastercard-logo.png" alt="Global PC accepts Mastercard"
                                        title="site accepts Mastercard" /></div>
                                        <div class="footer-payment-payment-express">
                                    <img runat="server" src="/images/payment-express.png" alt=" accepts Payment Express"
                                        title=" PC accepts Payment Express" /></div>
                            </div>
                        </div>
                    <div class="footer-social-media">
                        <div class="footer-title">
                            Social Media</div>
                        <div class="footer-facebook">
                            <a runat="server" href="http://www.facebook.com/" target="_blank">
                                <img runat="server" src="/images/facebook.png" border="0" alt="Become a fan of on Facebook"
                                    title="Become a fan of  on Facebook" /></a>
                        </div>
                    </div>
                    <div class="footer-links-left">
                        <div class="footer-title">
                            Shopping</div>
                        <a href="/">Home</a><br />
                        <a href="/cart.aspx">View cart</a><br />
                        <a href="/promotions.aspx">Promotions</a><br />
                        <a href="/create-account.aspx">Create Account</a>
                    </div>
                    <div class="footer-links-right">
                        <div class="footer-title">
                            About </div>
                        <a href="/contact-us.aspx">Contact us</a><br />
                        <a href="/about-us.aspx">About us</a><br />
                        <a href="/contact-us.aspx">Stores</a><br />
                        <a href="/suppliers.aspx">Suppliers</a><br />
                        <a href="/feedback.aspx">Feedback</a>
                    </div>
                    <div class="footer-legal">
                        <div class="footer-title">
                            Legal Information</div>
                        <a href="/terms.aspx">Terms and Conditions</a><br />
                        <a href="/privacy.aspx">Privacy policy</a><br />
                        <asp:Label ID="lblCopyright" runat="server"></asp:Label>
                    </div>
                </div>
            </div>
        </div>

    </div>

    </form>
    <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
        try {
            var pageTracker = _gat._getTracker("UA-8649565-1");
            pageTracker._trackPageview();
        } catch (err) { }</script>
</body>
</html>

网站标题
免费电话
项目:
  • 登录 使用3D安全保护在线支付 社会化媒体 购物


    关于



    法律信息

    var gaJsHost=((“https:==document.location.protocol)?”https://ssl." : "http://www."); write(unescape(“%3Cscript src=”+gaJsHost+“google analytics.com/ga.js”type='text/javascript'%3E%3C/script%3E”); 试一试{ var pageTracker=_gat._getTracker(“UA-8649565-1”); 页面跟踪器。_trackPageview(); }捕获(错误){}
    您没有对条件语句使用正确的PHP语法

    这里有一个固定版本:

    <div id="toggleView">
    <?php if ( $fixedwidth == '1' ) { ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=0">Switch to Mobile site</a>
    <?php } else { ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=1">Switch to Full site</a>
    <?php } ?>
    </div>
    

    为了让这成为一个真实的答案,从评论和您的编辑中可以看出,您正试图将PHP代码写入一个ASPX文件,而该文件的语言设置为C#,这就是它无法工作的原因


    您需要使用ASP.net的模板语法(而不是PHP)重写它。

    实际上@Zsw您可以,这正是应该发生的事情!:)IDK如果这是OP想要的,那么…这是设置
    fixedwidth
    的方式中的一个问题?我认为,由于缺少
    <div id="toggleView">
    <?php if ( $fixedwidth == '1' ) { ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=0">Switch to Mobile site</a>
    <?php } else { ?>
        <a href="<?php echo $_SERVER["SCRIPT_NAME"] ?>?fixedwidth=1">Switch to Full site</a>
    <?php } ?>
    </div>