So I was taking a PHP exam...



  •  I was on Freelancer.com and I decided that maybe taking a PHP exam will get people to hire me. One of the questions was this:

     

    [img]http://farm3.static.flickr.com/2790/4497554452_0e869f6ec3_o.png[/img]

     

    Yes, four of the options are blank, but the one that isn't seems to be ASP.



  • PHP has a configuration option to use ASP style tags.

    From php.ini:

    ; Allow ASP-style <% %> tags.
    asp_tags = Off



  • @jchannell said:

    PHP has a configuration option to use ASP style tags.

    From php.ini:

    ; Allow ASP-style tags.
    asp_tags = Off

    What's the configuration option to make include file="time.inc" valid PHP?



  •  I just looked up including files in ASP; apparently it's done <!-- #include file="filename.inc" -->

    So I really have no idea what that is.



  • @arxanas said:

     I just looked up including files in ASP; apparently it's done <!-- #include file="filename.inc" -->

    So I really have no idea what that is.

    Presumably it's meant to trip-up people who come from ASP backgrounds but can't quite remember how PHP includes files.  It's close enough to being ASP that it might snag a few people, although it honestly seems like a better question on an ASP test.



  •  The <% %> stuff is eRuby syntax, but I don't think Ruby's include would parse the file="time.inc" part.



  • The file="time.inc" part makes it look like JSP syntax, but not quite. The JSP include directive would look like this:

     <%@ include file="time.inc" %>

    Note the @ at the beginning.

     



  • @Tacroy: I dunno, if that returns "time.inc" it might. Although, the # is a comment in Ruby, I thought, so I'd think it would ignore the thing altogether.



  • It looks like perl syntax to me.



  • @morbiuswilters said:

    @jchannell said:

    PHP has a configuration option to use ASP style tags.

    From php.ini:

    ; Allow ASP-style tags.
    asp_tags = Off

    What's the configuration option to make include file="time.inc" valid PHP?

    There isn't one. ;)


  •  Maybe you could define "include" as a single-line comment?



  • @arxanas said:

    I dunno, if that returns "time.inc" it might. Although, the # is a comment in Ruby, I thought, so I'd think it would ignore the thing altogether.
    The original has no # character.  But [code]include file="time.inc"[/code] would accomplish the same thing as [code]include 'time.inc'[/code] because assigment does return the string.  However,  [code]include 'time.inc'[/code] will give you a type error because include takes a Module, not a string, and serves a purpose completely different than including a file.  Ruby includes other files with load or (typically) require.



  • You guys are all missing the point.  He only has 9:59 left to finish the test!  Assuming it gave him a total of 10:00 to complete it, that means he hit printscreen immediately upon seeing it, rather than investigating whether it is in fact a WTF first. 

    Hey, people do strange things under stress.  I know I'd have to be under a good bit of stress to take a PHP exam.



  • @belgariontheking said:

    He only has 9:59 left to finish the test!  Assuming it gave him a total of 10:00 to complete it,
    ...and assuming also the fact he's at question 12/40, then he must be Flash Gordon. WTF indeed.



  •  I had fifteen minutes, for your information, and I passed, anyways. I wonder what the right answer was...



  • @toshir0 said:

    It looks like perl syntax to me.

     

     

    Extremely poor Perl syntax recognizer detected.

     Perl has no fewer than three keywords for including source files, and none of them are "include." Plus, where's the part where somebody held down a shift key and banged on the numbers for a while?

     



  • @friedo said:

    @toshir0 said:

    It looks like perl syntax to me.


    Extremely poor Perl syntax recognizer detected.

    Perl has no fewer than three keywords for including source files, and none of them are "include." Plus, where's the part where somebody held down a shift key and banged on the numbers for a while?

    Clearly it's ASP.  Active Smalltalk Pages.



  • AFAIK the correct answer is:

    <?php
        ... php code ...
        require( "time.inc" );
        ... more php code ...
    ?>
    

    I never use "include" because it doesn't fail if the target file can't be found. "require()" is for inline code, "require_once()" is for function definitions.

    And, by the way, whenever any of us posts a screenshot, PLEASE crop it or shrink it or snapshot a smaller window! I had to resize my browser to 150% of my screen width in order to see this!



  • @AndyCanfield said:

    And, by the way, whenever any of us posts a screenshot, PLEASE crop it or shrink it or snapshot a smaller window! I had to resize my browser to 150% of my screen width in order to see this!
    Yes, let's all be sure to take Andy's 64x48 pixel browser window into account when posting WTFs.



  • @bstorer said:

    @AndyCanfield said:

    And, by the way, whenever any of us posts a screenshot, PLEASE crop it or shrink it or snapshot a smaller window! I had to resize my browser to 150% of my screen width in order to see this!
    Yes, let's all be sure to take Andy's 64x48 pixel browser window into account when posting WTFs.

    Dude, I resized my browser to 1024x768 and could still see the resulting WTF...



  • @bstorer said:

    Yes, let's all be sure to take Andy's 64x48 pixel browser window into account when posting WTFs.

    Yes, and let's all be sure to be especially cruel to people who patently have some kind of visual defect or disability which requires them to use either a 'small' screen resolution or a screen magnifier.

    That's nearly as bad as being so stupid as not to figure out that the original WTF is merely a) screwed-up HTML and/or b) a missing or mis-named file.



  • @AndyCanfield said:

    And, by the way, whenever any of us posts a screenshot, PLEASE crop it or shrink it or snapshot a smaller window! I had to resize my browser to 150% of my screen width in order to see this!
    Cropping the image is a simple matter of being polite.

    But whenever someone's posts a too-wide image, I just right-click and select "View Image" — and bam!, I have a nice tab with a zoomed out image, and scrollbars if I zoom back in.

    Alternatively, I could use Firebug to add p { overflow: auto } to the page's CSS, but that's a bit more involved.



  • @Zecc said:

    But whenever someone's posts a too-wide image, I just right-click and select "View Image" — and bam!, I have a nice tab with a zoomed out image, and scrollbars if I zoom back in.
    Yeah.  On the one hand, if you make your post readable, you won't get people whining about too wide jpg artifacts, etc. and it makes your point better, but on the other hand, quit whining!  You sound like morb.



  • @Cad Delworth said:

    @bstorer said:

    Yes, let's all be sure to take Andy's 64x48 pixel browser window into account when posting WTFs.

    Yes, and let's all be sure to be especially cruel to people who patently have some kind of visual defect or disability which requires them to use either a 'small' screen resolution or a screen magnifier.

    Oh, fuck people with disabilities.  I'm sick of complicating the process to appease them.  Why are their problems suddenly my problems?  Accessibility is only worthwhile when the disabled are a target audience. 


  • @bstorer said:

    Oh, fuck people with disabilities.

    Take what you can get, I guess.



  • @Someone You Know said:

    @bstorer said:

    Oh, fuck people with disabilities.

    Take what you can get, I guess.

     

    They can't run away, see.



  • @Cad Delworth said:

    Yes, and let's all be sure to be especially cruel to people who patently have some kind of visual defect or disability which requires them to use either a 'small' screen resolution or a screen magnifier.

    Yes, let's!  Really, though, it's now "especially cruel" to post a slightly-larger-than-necessary image on the Internet because some blind fuck might have to resize a window?

     

     

    @Cad Delworth said:

    That's nearly as bad as being so stupid as not to figure out that the original WTF is merely a) screwed-up HTML and/or b) a missing or mis-named file.

    What the hell are you babbling about?  I think everybody figured it was screwed-up HTML or missing entries in the DB (if they're storing questions and answers in text files, that's a secondary WTF) as soon as they read it.  Instead of stating the obvious, we argued over which language the only visible answer was.



  • @dhromed said:

    @Someone You Know said:

    @bstorer said:

    Oh, fuck people with disabilities.

    Take what you can get, I guess.

     

    They can't run away, see.

    Nor can they pick you out of a line-up without a telescope.



  •  @friedo said:

    @toshir0 said:

    It looks like perl syntax to me.

     

    Extremely poor Perl syntax recognizer detected.

    Extremely good 'Perl noob' recognizer detected.

    Congratulations. As you easily spotted it, I don't know a fuck about Perl. Just tried to googlecodesearch the snippet and the only files to come up were .pl and .pm files...



  • @arxanas said:

     I had fifteen minutes, for your information, and I passed, anyways. I wonder what the right answer was...

     Well most of the forums agrees that it wasn't <% include file="time.inc" %>. I would guess it was , but  is also a possibility.



  • @Abdiel said:

    @arxanas said:

     I had fifteen minutes, for your information, and I passed, anyways. I wonder what the right answer was...

     Well most of the forums agrees that it wasn't <% include file="time.inc" %>. I would guess it was , but  is also a possibility.

    Amazingly, I just realized this is one character (and one disabled-by-default php.ini option) from actually working.  We already know PHP can use ASP-style tags.  Also, include() is a special language construct, meaning it doesn't require parens around the argument.  Finally, PHP has the same behavior noted in other languages, that an assignment "returns" the value assigned.  The only problem is that "file" by itself is not a valid variable name, and hence causes a parse error.  <% include $file="time.inc" %> actually includes the file.


Log in to reply