SitePoint Sponsor

User Tag List

Page 9 of 9 FirstFirst ... 56789
Results 201 to 219 of 219

Thread: PHP Quiz

  1. #201
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    the second define should be
    PHP Code:
    define('SS''c'0); 
    Arg!

    Ok, I forgot about the freaking C constant.

    PHP Code:
    define('S' strtoupper(str_rot13(f)), 'c'0);
    /*
    01234567890123
    fghijklmnopqrs
    strtoupper to S
    SS, 'c', 0
    */ 
    Quote Originally Posted by cyborg from dh
    You made another obvious mistake, however you've simplified it so much i'm not sure why you stopped, being so close and all....
    I wonder what that was. Still don't see it. I'm redoing what I had, so maybe I'll spot it.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  2. #202
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still don't see the mistake. Oh well.
    PHP Code:
    define('C''f');
    define('SS''c'0);
    $d '2.';
    $q 'S';
    // list ($x, $y) = array('p', 'gg');
    $x 'p';
    $y 'gg';

    // $b = substr(str_rot13('a'.$x.'xy'.$y), 1, -4);
    /*
    apxygg ==  'a'.$x.'xy'.$y
    nckltt == str_rot13('apxygg')
    (there's a table on the php.net str_rot13 
    man page that helps with these)

    $b = 'c' == substr('nckltt', 1, -4)
    */

    $e 'a';
    $f 63;
    $c 'a' 12.5 63;

    ${
    'a1'.${((${'h'} = SS) ? ++$h 0)}.'5'.(($g 126 5) + ($g 1.5))} = (float) ($d . ($f 1.9047619047619));
    $a = ${${$b}};
    ob_start();
    var_dump(${$e});
    eval(
    '${S'.$q.'} = substr(strrchr(ob_get_contents(), substr(\'(\',0)), 1, -(int) substr($c, 2, -2)) . round(floor($$b));');
    ob_end_clean();
    echo $
    $b
    Last edited by samsm; Jun 23, 2003 at 10:13.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #203
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $c = ($e = 'a') . (25 / 2) . ($f = 22 | 45);

    how are you getting $c = 1 ....
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  4. #204
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know why but I was thinking that an assignment would return 1 upon success. Doesn't make much sense upon reflection. Fixed it now, in the code above.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #205
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since nobody is asking and I have a problem I can't seem to fix easily... I wanted to ask you guru types this:

    I want to know at the bottom of my pages how long php took to parse ...

    How do I do this with as little code possible???
    the neigbours (free) WIFI makes it just a little more fun

  6. #206
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    //at top of page
    $start microtime();
    .
    .
    .
    //at end of page
    $end microtime();
    $timeelapsed date('i:s',($end $start));
    ?>
    Aaron Brazell
    Technosailor



  7. #207
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a note, someone has to answer the last question before a new question can be asked, but we'll let you off this time
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #208
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry...thought it was already answered.
    Aaron Brazell
    Technosailor



  9. #209
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah that was supposed to be quoting the person who posted the question, not you, but whatever, lol, forgot to check the 'Quote Message in Reply?' checkbox.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  10. #210
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    Just a note, someone has to answer the last question before a new question can be asked, but we'll let you off this time [img]images/smilies/wink.gif[/img]
    Yeah I thoughed it was anserwed too..
    Just shows I do find it interesting but It's out of my leage [img]images/smilies/rolleyes.gif[/img]
    the neigbours (free) WIFI makes it just a little more fun

  11. #211
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Elsewhere
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I spent some time on the previous question (I thought it should be possible to find an easy solution using serialization and/or regex's). After a while I noticed you don't need to array_flip() function...

    PHP Code:
    foreach(array_reverse(array('Apple'=>'Jobs','Microsoft'=>'Gates','Oracle'=>'Ellison','Sun'=>'McNealy'))as$k=>$c)$n[strtolower(strrev($c))]=strtolower(strrev($k)); 
    An alternative solution using array_pop():

    PHP Code:
    for($s=array('Apple'=>'Jobs','Microsoft'=>'Gates','Oracle'=>'Ellison','Sun'=>'McNealy');$k=end($s);array_pop($s))$n[strtolower(strrev($k))]=strtolower(strrev(key($s))); 
    I'll post my solution to cyborg's question later today, unless someone else is still trying to solve it... (it's not extremely hard if you use the php manual)

  12. #212
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Azmo
    I'll post my solution to cyborg's question later today, unless someone else is still trying to solve it... (it's not extremely hard if you use the php manual)
    Go ahead (as far as I'm concerned, at least)!
    I'm lacking ambition.

    Good modification of the Apple=> Jobs puzzle, by the way.

    Post another puzzle when you post the cyborg solution!
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  13. #213
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Elsewhere
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, here it is...

    /*** CODE ***/ == original code
    // COMMENT == refactoring

    PHP Code:
    define('C''f');

    /*** define('S' . strtoupper(str_rot13(C)), 'c', 0); ***/
    // str_rot13(C) == str_rot13('f') == 's'
    // strtoupper('s') == 'S'
    define('SS''c'0);
    $d '2.';
    $q 'S';

    /*** list ($x, $y) = array('p', 'gg'); ***/
    $x 'p';
    $y 'gg';

    /*** $b = substr(str_rot13('a'.$x.'xy'.$y), 1, -4); ***/
    // str_rot13('apxygg') == 'nckltt'
    // substr('nckltt', 1, -4) == 'c'
    $b 'c';

    /*** $c = ($e = 'a') . (25 / 2) . ($f = 22 | 45); ***/
    // 22 | 45 == 63
    $e 'a';
    $c 'a12.563';

    /*** ${'a1'.${((${'h'} = SS) ? ++$h : 0)}.'5'.(($g = 126 / 5) + ($g * 1.5))} = (float) ($d . ($f * 1.9047619047619)); ***/
    // ((${'h'} = SS) ? ++$h : 0)
    // $h = SS returns 'c', which isn't FALSE, so we increment $h by one, making it 'd'.
    // Using ++$h means the if statement returns 'd', not 'c'.
    $h 'd';
    // (($g = 126 / 5) + ($g * 1.5)) == 25.2 + 37.8 == 63
    // ${'a1'.${'d'}.'5'. 63} == $a12.563
    // $d . ($f * 1.9047619047619) == '2.' . 120 == '2.120'
    // (float) 2.120 == (float) 2.12
    $g 25.2;
    ${
    'a12.563'} = (float) 2.12;

    /*** $a = ${${$b}}; ***/
    // ${$b} == $c
    // ${$c} == ${'a12.563'}
    $a = ${'a12.563'};

    ob_start();

    /*** var_dump(${$e}); ***/
    // ${$e} == $a
    var_dump($a); // Stores "float(2.12) " in the output buffer (note the ending space).

    /*** eval('${S'.$q.'} = substr(strrchr(ob_get_contents(), substr(\'(\',0)), 1, -(int) substr($c, 2, -2)) . round(floor($$b));'); ***/
    // '${S'.$q.'}' == '${SS}' == '$c'
    // ob_get_contents() == "float(2.12) "
    // 'substr(\'(\',0)' == '\'('\'
    // 'strrchr("float(2.12) ", \'(\' )' == '"(2.12) "'
    // '-(int) substr($c, 2, -2)' == '-(int) substr("a12.563", 2, -2 )' == '-2'
    // 'round(floor($$b))' == 'round(floor($c))' == 'round(floor("a12.563"))' == '"0"'
    eval('$c = substr("(2.12) ", 1, -2) . "0";');

    ob_end_clean(); // Discards the output buffer's contents.

    /*** echo $$b; ***/
    echo $c
    So the answer is '2.120'.

    Someone else can post the next question, I'm all done PHPing for a while.

  14. #214
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good work
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  15. #215
    SitePoint Enthusiast lupulet's Avatar
    Join Date
    Oct 2001
    Location
    romania
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php quizzes?

    Does anyone know where i could find php quizzes and/or tests?

    I must hire a php programmer and i want to give some written tests...

    Thx.
    you'll never be what you desire

  16. #216
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    This is a great thread.

    I am bumping this because i think it is an excellent thread. Just reading the first 4 pages of it has provided me with ideas and concepts I wan't even aware of.

    Good stuff!
    ]

  17. #217
    SitePoint Member sumaira120's Avatar
    Join Date
    Jul 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy didnt understand :(

    Salam to all

    <?php

    $i = 'Z';
    echo ++$i;

    ?>


    regarding above example ... i am little confused ... wht result is AA

    if there is value

    $i = 'Y';

    then result will be Z not ZZ ??

    may be its simple but i didnt understand it ??

    Any help ???

    Reagrds

  18. #218
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    W Salam sumaira120
    As to think on ur question i am also confused.
    but one thing in my mind that loop or incremented z runs two times
    to ending the alphabathic series then jump to single A..
    This is my assupmtion may be some people not agree or may i am
    wrong.
    Thanks
    ARIF.

  19. #219
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sumaira120 View Post
    Salam to all

    <?php

    $i = 'Z';
    echo ++$i;

    ?>


    regarding above example ... i am little confused ... wht result is AA

    if there is value

    $i = 'Y';

    then result will be Z not ZZ ??

    may be its simple but i didnt understand it ??

    Any help ???

    Reagrds
    Z goes to to AA. AZ goes to BA. BZ goes to CA... etc.

    Think of it as numbers, but instead of 0-9 you have A-Z.
    PHP | MySQL | (X)HTML | CSS


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
  •