Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. There is nothing wrong with using year 0 (it equates to 2000). The problem is using day 0: a month starts with day 1 and 0 means the last day of the previous month. Just change the day parameter from 0 to 1.
  2. That code isn't meant to display anything, does it not return the value that you want? Is $url what you want it to be? Is $data?
  3. What is the actual XML that you're retrieving (use $xml->saveXML() to see it)?
  4. I think (my memory isn't what it used to be) this might have been "fixed" for 5.3.0... I'll take a look-see for more info. P.S. Yep looks like 5.2 still suffers (just tried 5.2.11) and 5.3 (tested on 5.3.0) works as your post says. If that's the case, the note on the manual page will get amended.
  5. In your A::init() method, you create a new instance of "self" (in other words A) and return it. So, $b has an instance of the class A. When $b->ouput_text() is called, static refers to the class to which it belongs (A). When B::output_text() is called, ditto (B). You then make $b an instance of class B, so $b->output_text() uses static pointing to class B. When you say "doesn't print out the static::text value", it actually does; just that the value is NULL (so outputs an empty string). If I can understand your intentions correctly, your A::init() method should be doing $obj = new static;
  6. The link in the quote does not work, it's a 404 page not found error: http://southcoast.craigslist.org/sss/pts/1443545972.html The "/sss" part should not be there.
  7. Not inside character classes; [.] will match a literal dot only.
  8. If there are any lowercase letters, you'll likely need to make the pattern case-insensitive (with the i modifier) or extend the character class to include lowercase letters: /^[0-9A-F]{6}$/Di or /^[0-9a-fA-F]{6}$/D respectively (note both use the D modifier, more info).
  9. For what it's worth, this is mentioned in the documentation for preg_replace: see the third paragraph in the section describing the replacement parameter.
  10. Well, it does but also some other whitespace characters and only in certain circumstances. Just for reference, for the OP or whoever might want to know, it: 1. Replaces each carriage return (\r), line feed (\n), and tab (\t) character with a single space (\x20) 2. Collapses all consecutive spaces into a single space 3. Removes all leading and trailing spaces P.S. Wow, troll much? :-\
  11. The problem is preg_replace getting "confused", in a sense. Consider the following: $subject = "foobar"; $baz = "9"; $replace = "$2$1$baz"; $replaced = preg_replace("/(foo)(bar)/", $replace, $subject); $replace will contain the string "$2$19". This is fed into preg_replace which looks for capturing group #2 (which contains foo) and #19! That does not exist, so it will be substituted with an empty string leaving $replaced to contain just bar. Bear in mind that these dollar replacements can only go up to 99, this is important for your particular problem. With the replacement string of "$1=$2$newvalue\n", the value "$1=$224em\n" will be passed in to be replaced. It will then try to substitute $1 which exists with value "LeftWidth", and $22 which doesn't exist so gets a value of "[/tt]" (empty string) leaving us with "[tt]LeftWidth=4em". To resolve this issue, you need to change the way you reference the dollar replacements. First, wrap the number in curly braces to make it clear which number we are referring to ($2 becomes ${2}). Next, because we're using double quotes we need to escape the dollar else the parser will look for an actual variable called $2 (which does not exist): ${2} becomes \${2}. To put this into your example, the replacement string should be "$1=\${2}$newvalue\n". P.S. cags beat me to it, really need to learn to get around to reading and answering more quickly.
  12. I didn't look at the code very closely (tired, having trouble seeing straight!) but it looks like the SplDoublyLinkedList (part of the SPL) but with, as you say, a Java-inspired interface. P.S. Mark said the same thing; that'll teach me to open threads in tabs and take a while to get around to answering them!
  13. salathe

    Salathe

    nadeemshafi9, PHP is (as you know) open source so anyone is welcome to contribute patches to amend, fix or otherwise change existing features or add new ones. Sign up to one or more of the mailing lists (e.g. 'internals' for PHP itself or 'phpdoc' for the documentation) to get a feel for the discussions.
  14. salathe

    Salathe

    cags, if you look for "junior" rules then they're usually much more open to people fresh out of university or coming in from elsewhere with little to no commercial experience. Don't expect to jump into a senior role right away even if you know your stuff really well. SemiApocalyptic, thanks. Hello.
  15. salathe

    Salathe

    Currently I'm getting through the "Emperor" series of books by Conn Iggulden and am generally interested in medieval or earlier subjects (including the "timeshift" style of writing) with at least some basis in fact. That said, I'll read anything once!
  16. Let us know how you get on after reading/using the cheat sheet and we'll be able to move forwards from there.
  17. salathe

    Salathe

    I only introduced myself yesteday in the mammoth introductions thread so will just reiterate what was said in there for my new introduction thread. Well, I'll keep it brief. Here are the usual details: I'm a 25 year old from Lancashire, England and mainly joined this place to be part of a more mature community (both in terms of the people and the site itself). Academically, I have an MA in Archaeology from Edinburgh University (usually spend a couple of months every summer out in the field) and maybe some day I'll move over to that side of the fence for my career. As it stands now, I'm a PHP developer (currently unemployed) and am really pushing on with that as it is something that I love (and appear to be competent at). I'm also a contributor to the PHP documentation (), trying to give something back to a resource that has been really useful to me over the years. I enjoy reading (historical novels seem to be a current trend) and like to relax in front of a movie, when I'm not lurking in the regex forum—an area where lots of people seem to struggle and I can help out a little bit (it's difficult to find threads which haven't already been answered in the other forums!). Any questions, thoughts or indeed greetings are more than welcome.
  18. Thanks for asking, it's a very common question. PHP came first, I've been playing with it for well over a decade as a hobby, I like to solve puzzles (not necessarily literal puzzles/games) and programming has always seemed a good way of doing that. Archaeology only came along when I went to uni (unless you count "general interest" from TV shows and such like, it was never a hobby). They're also not quite as divergent as one might think, there is a lot of cross over betweenf programming and archaeology whether literally or in similar concepts or processes.
  19. Well, I'll keep it brief. Here are the usual details: I'm a 25 year old from Lancashire, England and mainly joined this place to be part of a more mature community (both in terms of the people and the site itself). Academically, I have an MA in Archaeology from Edinburgh University (usually spend a couple of months every summer out in the field) and maybe some day I'll move over to that side of the fence for my career. As it stands now, I'm a PHP developer (currently unemployed) and am really pushing on with that as it is something that I love (and appear to be competent at). I'm also a contributor to the PHP documentation (), trying to give something back to a resource that has been really useful to me over the years. I enjoy reading (historical novels seem to be a current trend) and like to relax in front of a movie, when I'm not lurking in the regex forum.
  20. You need to change: __Construct(MyFirstClass $firstClass){ getFirstClassVars($firstClass); printFirstClassVars(); } to: public function __construct(MyFirstClass $firstClass){ $this->getFirstClassVars($firstClass); $this->printFirstClassVars(); } If you don't know why, just ask.
  21. print_r has a second argument called $return which is a boolean (default false) dictating whether the formatted value is returned as a string (true) or output directly (false). $foo = array('a', 'b', 'c'); $debug = print_r($foo, TRUE); echo $debug;
  22. It would be much more intuitive to be able to do that, I agree. There is no concept of $this or self:: in these anonymous functions. You could pass the object ($foo) through to the function (in place of $this) using use and have Foo:: (in place of self::) but it's not a pretty solution.
  23. Also note that you won't be able to call $foo->bar() — you need to use call_user_func($foo->bar) or $foo->bar->__invoke()
  24. Just to clarify (it might not be clear for the OP), Daniel's code still does not define the 'bar' method, it assigns an anonymous function to the bar property (which might be fine).
  25. I was going to introduce myself, still being fairly new to the community—not too sure I want to now. Back to the regex forum for me. :-\
×
×
  • 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.