Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Serialization of DateTime objects was only added to the language in PHP 5.3.0. Just to show you that's the case, the following script was executed on many different versions. <?php $dt = new DateTime('2011-09-01', new DateTimeZone('UTC')); $serialized = serialize($dt); $unserialized = unserialize($serialized); echo $unserialized->format('r'); ?> The results were: -- 5.2.0 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.1 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.2 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.3 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.4 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.5 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.6 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.8 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.9 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.10 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.11 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.12 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.13 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.14 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.15 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.3.0 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.1 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.2 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.3 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.4 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.5 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.6 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.4.0 -- Thu, 01 Sep 2011 00:00:00 +0000 -- trunk -- Thu, 01 Sep 2011 00:00:00 +0000
  2. Not in public, m'dear. P.S. skwap, you need to swap the $mid and $url positions in the preg_match() call. Just to be sure you know what the problem is.
  3. Why do you want to combine two completely unrelated regular expressions, with two completely unrelated replacement values, into one?
  4. Easy. You say, "Because I have concerns informing my current employer/line managers that I am applying for other jobs, because they will go ballistic." It's just not something you'd write in a CV.
  5. Just in case it wasn't clear from the replies above, skwap, you have your arguments switched. $url and $mid should be the other way around. P.S. See, I can echo too!
  6. If the commit has only ever existed locally, then you're in luck. If the commit was pushed anywhere (anywhere!) then, depending on where the commit may have spread to, life could be painful. So, before offering solutions, exactly where is the commit now? Just in your local git repo, pushed to a super-tightly-controlled remote, only wherever your colleagues (if there are any) might have it, or potentially anywhere?
  7. You must be. Wingrep happily searches for literal dollar characters with \$
  8. Happy to help in guiding you in the right direction. What?
  9. Don't use regex. PHP has built-in XML parsing tools available to make the job much easier. One such tool is SimpleXML and the example below shows how to loop over each <item> and display the associated image. Have a read through the SimpleXML Examples page too. $feed = simplexml_load_file('http://feeds.nationalgeographic.com/ng/photography/photo-of-the-day.atom'); foreach ($feed->channel->item as $item) { printf('<img src="%s"><br>', $item->enclosure['url']); } (And here's it working online.)
  10. Your line of code is incorrect given the XML shown. $xml will be the <parent> element so to try and access the <street> you would want: $street = $xml->children('cmn', true)->address->street; If the <cmn:address> is not present, the above will assign NULL to $street with no warnings or errors.
  11. Will any code given in this thread find its way into your "best scripts and software" site?
  12. People who abuse their power are kept in their existing roles, or promoted.
  13. Is there any reason why you want to use regex over, say, a real HTML parser? A basic example would look a bit like: $doc = new DOMDocument; $doc->loadHTML($a); $h1 = $doc->getElementsByTagName('marquee')->item(0); echo $doc->saveXML($h1);
  14. I'm going to guess that "locally" you're using PHP 5.3 and "not locally" you're using PHP 5.2 (or lower). The former allows you to use a variable as you have, the latter does not. In short, prior to PHP 5.3.0 you must hard code the class name there.
  15. The "equivalent function" will vary depending on which XML-related classes/functions you want to use in place of the PHP 4 DOMXML. You will have to change far more than that one line of code. Options include: DOM SimpleXML XMLWriter
  16. Yes, the relative path will work. Remember that relative paths aren't necessarily relative to the file that the code is in, but instead the "current working directory".
  17. You can't use a web address with glob like that. Specify the folder path on the filesystem instead (e.g. C:\blah\something\images\gay).
  18. If you're using PHP 5.3, then use DateTime::createFromFormat() (if you're not, why not?!). $date = '15/05/2011'; $datetime = DateTime::createFromFormat('d/m/Y', $date); $mysql_date = $datetime->format('Y-m-d'); If you want to stick with strtotime() then formats that it will accept are detailed under Date Formats.
  19. It's hardly a fork at all, that name was given primarily to attract visitors (from what I've read). Some of the changes would be nice, others very welcome, others not so much at all. It would be worth mentioning that his approach sucked (publishing the changes without even attempting to talk to the PHP guys about merging them) but he has since come along and offered them up for discussion within PHP. Open source works best if the changes can flow upstream.
  20. Look in Zend/zend_highlight.c (and Zend/zend_language_scanner.c if you want your mind melted).
  21. Have a look at profiling your script (search "xhprof", "xdebug") to find out really where the slow parts of the script lie, rather than guessing.
  22. The function may be "slow" depending on the regular expression and replacements being made, though in most normal cases it is not "slow" at all. Have a look at profiling your script (search "xhprof", "xdebug") to find out really where the slow parts of the script lie, rather than guessing.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.