What's new
Guest viewing limit reached
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation
  • Already a member? Click here to login

PHP : Quiz of the Week!

Bob

Expert Talker
PF Member
Messages
664
Highlights
0
Reaction score
0
Points
102
Peak Coin
0.000000¢
DB Transfer
0.000000¢
Okay, I have decided to start this quiz of the week thing, which I will post every saturday, which I hope will provide a wee bit of a challenge and also help teach you small parts of PHP .. some of these will seem *incredibly* simple to people who know PHP, but to some people they will seem impossible, so remember .. its only easy when you know the answers.

I will be posting the answer and complete explanation of all the code used in each QotW (quiz of the week) on the Wednesday after I originally posted the quiz {i.e, you got saturday, sunday, monday, tuesday and parts of wednesday to answer the question :) }.


------------------------------------------------

The Code:
PHP:
<?php

$do = "A lot of work!";

echo $do;

?>

The Question:
What will this output to the user?
 
Maybe you're right, maybe you're not .. who knows? :) (Well, I do .. and lots of other people probably do, but still..)
 
Okay I don't know PHP at all..lol..but I'm going to take a crack at this :) Maybe I learn something...


Okay I'm assuming it's going to show you: A lot of work!

because:


<?php - tells it to call php

$do = "A lot of work!"; - this is a variable where you tell it what to type when called?

echo $do; - calling the variable

?> - end php

LOL is that even close?
 
'echo' usually represents the system echoing the input to the screen, so the 'echo $do' line is probably not really "calling" the variable, but rather echoing the input from the variable to the screen.

This is assumption based on previous programming experience, since I've never actually dealt with PHP.
 
Spyder, well .. I was actually going to give a full explanation of the code on Wednesday, but that one was maybe a bit too simple because everyone can get it.

PHP:
.. this is not executed by php ..

<?php // Tells the webserver to execute everything from here until the ? > (without the space in between.) in PHP.

$do = "A lot of work!"; // Creates the variable $do, and tells that variable its content is 'A lot of work!'.

echo $do; // Echos the content of $do (A lot of work!) to the user.

?> 

.. this is not executed by php ..

So, anyone whose answer was 'A lot of work!' was right.

Hmm, this didn't work as expected.
 
Here it is!

Here ya go! (I think:))
PHP:
<?php // Begin's the PHP Code

$do = "A lot of work!"; // Make's the variable, $do, which is A lot of work!

echo $do; // This Echo's what the variable $do is, in other words, it puts that variable there

?> // This End's the PHP Coding
 
Back
Top