小编wil*_*fun的帖子

如何使用php处理XML文件?

我的网关在购买时向我的服务器发送(发布)xml数据馈送.XML看起来像这样:

 <?xml version='1.0' standalone='yes'?>
 <foxydata>
<datafeed_version>XML FoxyCart Version 0.6</datafeed_version>
<transactions>
    <transaction>
        <id>616</id>
        <transaction_date>2007-05-04 20:53:57</transaction_date>
        <customer_id>122</customer_id>
        <customer_first_name>Dirk</customer_first_name>
        <customer_last_name>Gently</customer_last_name>
        <shipping_total>4.38</shipping_total>
        <order_total>24.38</order_total>
        <order_total>24.38</order_total>
                 <customer_password>1aab23051b24582c5dc8e23fc595d505</customer_password>
        <custom_fields>
            <custom_field>
                <custom_field_name>My_Cool_Text</custom_field_name>
                <custom_field_value>Value123</custom_field_value>
            </custom_field>
        </custom_fields>
        <transaction_details>
            <transaction_detail>
                <product_name>foo</product_name>
                <product_price>20.00</product_price>
                <product_quantity>1</product_quantity>
                <product_weight>0.10</product_weight>
                <product_code></product_code>
                <subscription_frequency>1m</subscription_frequency>
                <subscription_startdate>2007-07-07</subscription_startdate>
                <next_transaction_date>2007-08-07</next_transaction_date>
                <shipto>John Doe</shipto>
                <category_description>Default for all products</category_description>
                <category_code>DEFAULT</category_code>
                <product_delivery_type>shipped</product_delivery_type>
                <transaction_detail_options>
                    <transaction_detail_option>
                        <product_option_name>color</product_option_name>
                        <product_option_value>blue</product_option_value>
                        <price_mod></price_mod>
                        <weight_mod></weight_mod>
                    </transaction_detail_option>
                </transaction_detail_options>
            </transaction_detail>
        </transaction_details>
        <shipto_addresses>
            <shipto_address>
                <address_name>John Doe</address_name>
                <shipto_first_name>John</shipto_first_name>
                <shipto_last_name>Doe</shipto_last_name>
                <shipto_address1>2345 Some Address</shipto_address1>
                <shipto_address2></shipto_address2>
                <shipto_city>Some City</shipto_city>
                <shipto_state>TN</shipto_state>
                <shipto_postal_code>37013</shipto_postal_code>
                <shipto_country>US</shipto_country>
                <shipto_shipping_service_description>DHL: Next Afternoon</shipto_shipping_service_description>
                <shipto_subtotal>52.15</shipto_subtotal>
                <shipto_tax_total>6.31</shipto_tax_total>
                <shipto_shipping_total>15.76</shipto_shipping_total>
                <shipto_total>74.22</shipto_total>
                <shipto_custom_fields>
                    <shipto_custom_field>
                        <shipto_custom_field_name>My_Custom_Info</shipto_custom_field_name> …
Run Code Online (Sandbox Code Playgroud)

php xml

1
推荐指数
1
解决办法
430
查看次数

如果网址包含以下内容,请勿显示此内容

我有一个简单的div,如果访问者加载某个URL,我不想加载它.

它看起来像这样:

<?php
if( stristr($_SERVER['PHP_SELF'], 'blog') == FALSE  )
{

echo "<div id="stuff"></div>";

}
?>
Run Code Online (Sandbox Code Playgroud)

问题是......它不起作用......当我加载www.url.com/blog时,div#stuff仍然显示.

我只是缺乏睡眠或上述工作吗?如果网址包含博客,你会做什么没有div显示?

php wordpress

0
推荐指数
1
解决办法
5134
查看次数

如果然后用较少的重复声明,如何实现这一点?

我有一些简单的事情,我想用更少的重复来完成.

默认情况下,我想要显示一个div,但是如果$ x == 1,那么检查是否$ y!= 1,如果$ y没有,则不显示该块.

然而,我能想到的最好的是以下内容:

if($x) {

    if($y != 1) {

        echo '<div>display block</div>';        
    }

} else {

    echo '<div>display block</div>';

}
Run Code Online (Sandbox Code Playgroud)

这看起来有点重复.

我知道我可以调整一下,做一些像:

$displayBlock = '<div>display block</div>';

if($x) {

    if($y != 1) {

        echo $displayBlock;     
    }

} else {

    echo $displayBlock;

}
Run Code Online (Sandbox Code Playgroud)

但即使如此,我还是觉得有一种方法可以做到这一点,如果还有其他我现在看不到的东西.

如何用较少的if语句完成上述操作?所以:如果$ x!= 1(默认值),则显示displayBlock.如果$ x == 1,$ y!= 1,则显示显示块.如果$ x == 1 && $ y == 1,则不显示displayBlock.

php

0
推荐指数
1
解决办法
90
查看次数

每个间隔在元素上附加一个点

我有一个简单的'处理' 点等待...点等待...点等待..当用户提交表单时.

我认为这可以通过类似的东西轻松完成

<h2>Processing</h2>
Run Code Online (Sandbox Code Playgroud)

$(document).ready(function(){

  setTimeout($('h2').append('.'), 500);

});
Run Code Online (Sandbox Code Playgroud)

然而,它得到第一个点,然后抛出一个错误:

Uncaught SyntaxError: Unexpected identifier
Run Code Online (Sandbox Code Playgroud)

我的逻辑在哪里失败了?什么是意外的标识符?

javascript jquery

0
推荐指数
1
解决办法
413
查看次数

标签 统计

php ×3

javascript ×1

jquery ×1

wordpress ×1

xml ×1