php-general Digest 19 Apr 2013 20:16:14 -0000 Issue 8200

Topics (messages 320879 through 320883):

Re: <?=$var?>
        320879 by: Lester Caine
        320880 by: Larry Martell
        320881 by: Micky Hulse

Re: Date weirdness
        320882 by: Larry Martell

Newbie Question - Parse XML with PHP...
        320883 by: dealTek

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Larry Martell wrote:
Continuing in my effort to port an app from PHP version 5.1.6 to
5.3.3, the app uses this construct all over the place when building
links:

<?=$var?>

I never could find any documentation for this, but I assumed it was
some conditional thing - use $var if it's defined, otherwise use
nothing. In 5.1.6 it seems to do just that. But in 5.3.3 I'm not
getting the value of $var even when it is defined. Has this construct
been deprecated? Is there now some other way to achieve this?

There WAS a period when <?= was linked to short opening tag setting, which cause a number of headaches, but currently the two are now isolated!

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--- End Message ---
--- Begin Message ---
On Wed, Apr 17, 2013 at 5:02 PM, Micky Hulse <rgmi...@gmail.com> wrote:
> On Wed, Apr 17, 2013 at 3:59 PM, Micky Hulse <rgmi...@gmail.com> wrote:
>> You might need to turn on the short tag option
>> in your conf file.
>
> Sorry, ini file, not conf. Been a long day. :D
>
> I guess I should have asked if short tags are turned on for your 5.3.3?

That was it. Thanks!!

--- End Message ---
--- Begin Message ---
On Thu, Apr 18, 2013 at 8:36 AM, Larry Martell
<la...@software-horizons.com> wrote:
> That was it. Thanks!!

Np. Glad it helped. :)

--- End Message ---
--- Begin Message ---
On Thu, Mar 28, 2013 at 3:40 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> On Thu, Mar 28, 2013 at 2:44 PM, Steven Staples <sstap...@mnsi.net> wrote:
>>> I think I am losing my mind. I have some time zone converting code, and I
>>> just don't understand what I am seeing. Also my system seems to return the
>>> wrong time after I do some date operations on unrelated objects.
>>>
>>> This is from a machine that is in eastern time. I want to convert to, for
>>> example central time:
>>>
>>> $ndate = new Date(date("Y-m-d H:i:s"));
>>> echo $ndate->format("%Y-%m-%d %H:%M:%S");
>>> 2013-03-28 15:35:07  <- this is the correct time
>>>
>>> $ndate->setTZbyID("EDT");
>>> echo $ndate->format("%Y-%m-%d %H:%M:%S");
>>> 2013-03-28 15:35:07 <- still correct
>>>
>>> $ndate->convertTZbyID("US/Central");
>>> echo $ndate->format("%Y-%m-%d %H:%M:%S");
>>> 2013-03-28 10:35:07 <- this is wrong it should be 14:35:07
>>>
>>> $xdate = new Date(date("Y-m-d H:i:s"));
>>> echo $xdate->format("%Y-%m-%d %H:%M:%S");
>>> 2013-03-28 19:35:07 <- HUH? This is wrong - should be 15:35:07
>>>
>>> What in the world is going on here?
>>>
>>
>> I found this function a while back when I was converting UTC to EST... 
>> simple task I know, but still...
>>
>> ( I am sorry to whomever wrote this, I didn't keep the source where I found 
>> it )
>>
>> function convert_time_zone($date_time, $from_tz = 'UTC', $to_tz = 
>> 'America/Toronto')
>> {
>>         $time_object = new DateTime($date_time, new DateTimeZone($from_tz));
>>         $time_object->setTimezone(new DateTimeZone($to_tz));
>>         return $time_object->format('Y-m-d H:i:s');
>> }
>
> I don't seem to have the DateTime object. We are running 5.1.6 and
> that was added in 5.2.0. We are getting the Date module from an
> external extension. I'll have to see about upgrading.

I've upgraded to 5.3.3, got rid of the external Date extension and
implement your solution. It's working perfectly. Thanks much!

--- End Message ---
--- Begin Message ---
Hi all,

newbie - just starting with trying to parse XML...


$mylist = simplexml_load_file('thelist.xml');

then use a foreach to echo the data...

<?php
    $mysongs = simplexml_load_file('songs.xml');
    
    foreach ($mysongs as $songinfo) {
        $title=$songinfo->title;
        $artist=$songinfo->artist;
        $date=$songinfo['dateplayed'];
        echo $title.' --- ';
                echo $artist.' --- ';
                echo $date.' --- ';
                echo ' </br> ';
        }
    
?>

that I get ...

Question: how do you use $mylist when the xml is not as a file but is returned 
on a web page?


an example of the real xml I am trying to work with is like this demo below ....

Goal : when this response comes back - I would like to be able to get the data 
as php and then update the database....


example........
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <result>1</result>
  <result-text>SUCCESS</result-text>
  <transaction-id>1865264174</transaction-id>
  <result-code>100</result-code>
  <authorization-code>123456</authorization-code>
  <avs-result>N</avs-result>
  <cvv-result>N</cvv-result>
  <action-type>sale</action-type>
  <amount>12.00</amount>
  <ip-address>::1</ip-address>
  <industry>ecommerce</industry>
  <processor-id>ccprocessora</processor-id>
  <currency>USD</currency>
  <order-description>Small Order</order-description>
  <merchant-defined-field-1>Red</merchant-defined-field-1>
  <merchant-defined-field-2>Medium</merchant-defined-field-2>
  <order-id>1234</order-id>
  <tax-amount>2.00</tax-amount>
  <shipping-amount>0.00</shipping-amount>
  <billing>
    <first-name>John</first-name>
    <last-name>Smith</last-name>
    <address1>1234 Main St.</address1>
    <city>Beverly Hills</city>
    <state>CA</state>
    <postal>90210</postal>
    <country>US</country>
    <phone>555-555-5555</phone>
    <email>t...@example.com</email>
    <company>Acme, Inc.</company>
    <cc-number>400000******0002</cc-number>
    <cc-exp>0118</cc-exp>
  </billing>
  <shipping>
    <first-name>Mary</first-name>
    <last-name>Smith</last-name>
    <address1>1234 Main St.</address1>
    <city>Beverly Hills</city>
    <state>CA</state>
    <postal>90210</postal>
    <country>US</country>
    <address2>Unit #2</address2>
  </shipping>
  <product>
    <product-code>SKU-123456</product-code>
    <description>test product description</description>
    <commodity-code>abc</commodity-code>
    <unit-of-measure>1</unit-of-measure>
    <unit-cost>5.0000</unit-cost>
    <quantity>1.0000</quantity>
    <total-amount>7.00</total-amount>
    <tax-amount>2.00</tax-amount>
    <tax-rate>1.00</tax-rate>
    <discount-amount>2.00</discount-amount>
    <discount-rate>1.00</discount-rate>
    <tax-type>sales</tax-type>
    <alternate-tax-id>12345</alternate-tax-id>
  </product>
  <product>
    <product-code>SKU-123456</product-code>
    <description>test 2 product description</description>
    <commodity-code>abc</commodity-code>
    <unit-of-measure>2</unit-of-measure>
    <unit-cost>2.5000</unit-cost>
    <quantity>2.0000</quantity>
    <total-amount>7.00</total-amount>
    <tax-amount>2.00</tax-amount>
    <tax-rate>1.00</tax-rate>
    <discount-amount>2.00</discount-amount>
    <discount-rate>1.00</discount-rate>
    <tax-type>sales</tax-type>
    <alternate-tax-id>12345</alternate-tax-id>
  </product>
</response>








--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


--- End Message ---

Reply via email to