SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: echo question

  1. #1
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    echo question

    Why is this so:

    when I do this :

    PHP Code:
    echo 001600
    it returns 896

    Don't Panic

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    My guess would be PHP is reading that as a pre defined variable in the PHP core

  3. #3
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any solution for this?

    $a = '009699';

    if ($a > 001600){
    return true;
    }
    Don't Panic

  4. #4
    SitePoint Guru bronze trophy TomB's Avatar
    Join Date
    Oct 2005
    Location
    Milton Keynes, UK
    Posts
    989
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    Simple answer here, when you prefix a number with 0, php interprets it as an octal number (base 8), when you print it it gets converted to decimal. Remove the prefixed zeroes and it will work.

  5. #5
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomB View Post
    Simple answer here, when you prefix a number with 0, php interprets it as an octal number (base 8), when you print it it gets converted to decimal. Remove the prefixed zeroes and it will work.
    well it is actually a mysql time format converted to a number something like this :

    PHP Code:
    $time 21:23:00
    $a 
    str_replace(':','',$time); 
    returns -> 212300

    Anyway I got it

    echo '001600';

    cheers !
    Don't Panic


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •