Tutorials:

23 Jun 2009

0

PHP For Beginners: Part III

If you haven’t seen the first two posts for this series, be sure to check them out below:

This exercise assumes that you either have PHP installed on your computer already or that you have access to a server with PHP support.

Some might call it an absence, I prefer to call it a long nap. Yes, I’m back, bringing with me part three of my PHP tutorial line! Follow the program throughout the summer as I provide you at least weekly updates on this versatile language of Web 2.0.

Lets get down and dirty. This lesson will cover the following:

  • More operators
    • Concatenation operator
    • Combined assignment operators
    • Comparison operators
  • Incrementing and Decrementing
    • Operator precedence
  • Constants
  • Quiz

More Operators

Arithmetic Operators were discussed in part two of this series, but I’m sorry to say that was just the surface. Operators are necessary to manipulate information and data values to create a result desirable to the author. Thus, the more operators, the more possibilities of the script, and thus the more objectives achieved with the code! These operators are fairly common among any programming language that you find, but their unique use in PHP is what helps make it such a strong language.

Concatenation operator

We’ll start out simple. The concatenation operator is a single period (.) that essentially binds together two operands (remember, these are expressions or strings, basically values of data or information). This may not seem important now, but this operator is important in combining the results of an expression with some kind of string. Here’s an example:

$centimeters=245;
print “The width is “.($centimeters/100).” meters”;

Here I used a variable then printed it within a string operand. This script will return the output “The width is 2.45 meters”.

Combined assignment operators

Compacting code is important in a website because it means that you have fewer things to sift through when troubleshooting. Shorter code also means a smaller file size, and if you intend to enter into a serious programming profession then that is a huge plus.

The name “combined assignment operators” is pretty much the exact description of this entire section. Basically, we combine the functions of two operators into one in an effort to simplify the code. Below is an example:

$x=4;
$x=$x+4; //$x now equals 8
$x+=4; //$x now equals 12 by the combined operator

Here is a table detailing just a few of the basic combined operators:

Combined Assignment Operators

Operators

Comparison operators

Pretty simple so far right? Well here’s where one of the biggest parts of PHP comes into play: comparison operators. Comparison operators perform tests on their operands, returning the boolean result true or false. This is again important for relating various pieces of information to one another from the user input.

We’ll just be getting familiar with them for right now; we’ve already covered a lot this lesson and this is a very important topic to fully comprehend. For right now, it is important to understand that these values are equivalent to true or false; they do not actually return the boolean value. For example:

$x=4;
$x<9; // equivalent to the value true
$x>23; // equivalent to the value false

Below is a table of comparison operators. We will learn more about these in complex coding sequences next lesson.

Comparison Operators

Comparison Operators

Incrementing and Decrementing

Incrementing and decrementing, which is increasing or decreasing by one, respectively, is a handy little ability when it comes to integrating loops into your code. For example, say that you want the script to execute a certain operation eight times; you can’t simply say “do this eight times.” Instead, you must say “start at one, then at the conclusion of each execution, add one to this number. When the number reaches eight, stop executing the function.” This method is seen in almost every programming language so mastery of this is crucial in order to learn other languages with ease.

This tutorial guide has already showed you two ways to increment and decrement a variable: the arithmetic operator and the combined operator. Below are examples of this:

$x=$x+1; // incremented by 1
$x-=1; // decremented by 1

Because changing a variable by the value of one is so important, however, the whole operation has received its own operator! Below are the respective operators for incrementation:

$x++; // $x is incremented
$x--; // $x is decremented

Putting them together into a little test code, we receive the following:

$x=3;
$x++<4; // true

But hold on, if we refer to our comparison operators, we’ll see that the < sign means only less than. How can this function return true then? It’s true because the variable x is evaluated in the function BEFORE being incremented. THIS IS VERY IMPORTANT! In order to increment the variable before evaluation, you must do the following:

++$x; // incremented
--$x; // decremented

Now to replace it in the above code:

$x=3;
++$x<4; // false

Operator precedence

The above argument brings us into operator precedence, or what most people will be familiar with, what I like to call “order of operations.” Certain operators have precedence over one another in this wonderful language PHP. Below is an example:

4+5*2 // returns 14, multiple first
(4+5)*2 // returns 18, parentheses first

This is a pretty straightforward concept that you just need to familiarize yourself with. Beyond that, this table is just for basic reference:

Order of Precedence for Selected Operators

Order of Precedence for Selected Operators

I know that we have not yet touched numbers 9, 10, or 11, but hold on to your knickers because they’ll be there next lesson!

Quiz

School is fun, especially in the summer! That’s why I’ve included this quiz. That, and to help you retain your knowledge of what we’ve just learned. Don’t peak back!

#1: Which of the following will increase $x by 2?

  1. ++$x++
  2. $x + (3/2)
  3. 4*2/6 + $x

#2: 4*9+9+(4/1) will return the following:

  1. 49
  2. 76
  3. 39

#3: 4.0===4 will return the value TRUE.

  1. True
  2. False
  3. Not enough information

#4: The expression $x*=2 is equal to:

  1. $x=$x*$x
  2. $x=$x^2
  3. $x=$x*2

#5: Without looking, which operator is executed first from this list?

  1. + -
  2. &&
  3. ||

Answer key: A,A,B,C,A

Conclusion

That’s all folks! We’ve taken some great steps today, and hopefully we will take many more in my next tutorial, PHP for Beginners: Part IV.

04 Jun 2009

2

Predefined Variables in PHP: For complete beginners

This is an overview made for beginners: and introduction to predefined variables in PHP. We’ll go over what they are, where you’ve probably seen them, and how and when to use them.

What are predefined variables?

Predefined variables in PHP are exactly what they sound like — variables in the PHP language that have been defined already. They can use used in any PHP script, with no need to create them yourself. They serve a purpose that is commonly used among programmers repeatedly, such as passing information from a form to a PHP script ($_POST would be used for this).

Here is the list of currently defined variables in PHP. Of course, you don’t need to understand all of these quite yet, but they can come in handy for any PHP developer.

All of these variables interact with the current server in some way. This means their purpose is to either get information from the server (e.g. Find the IP address of the user) or translate information to the server (e.g. send a user’s information from a form through the server to be handled by a PHP script.)

Let’s now get a closer look at some of the most commonly used predefined variables.

$_SERVER

This variable is an array of values, with the values containing information about the server.

If you don’t know what an array is, it’s quite simple: it is a collection of values, put into one component. For example, an array of numbers would be “1, 4, 6, 3, 3″. All these numbers can be stored in one place, called an array. The array can then be assigned to a variable name, like “$numbers”. There are more formal definitions of an array, as this definition may not be 100% ‘accurate’. However, it’s a good outline and way to think of arrays.

Let’s say we’re creating a fluid layout, and because different browsers handle pixels differently, we want to determine the browser type of the user so we can lead them to a specified stylesheet. This way, we can make sure a fluid layout never breaks.

In the PHP $_SERVER array (collection), there is one piece called “HTTP_USER_AGENT”. This piece of the array (index of the array) contains the user’s browser information. We can call it like so:

$_SERVER["HTTP_USER_AGENT"];

To see it in action, let’s echo it out:

<?php
     echo $_SERVER["HTTP_USER_AGENT"];
?>

The code above will return browser information in the form of a string. My browser information looks like this:

Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
     (.NET CLR 3.5.30729)

I won’t get too into it, but from here on we can see how we can use this information to specify a certain stylesheet for a user. If we store that String in a variable, (or part of the string), and send it through an if/else statement, we can give the user the correct stylesheet.

Note: This is just pseudo code below!

$browserType = $_SERVER["HTTP_USER_AGENT"];

if $browserType = "Mozilla..."
     then [switch user to the Mozilla Firefox stylesheet]

else if $browserType = "Internet Explorer..."
     then [switch user to the IE stylesheet]

else [use the default stylesheet]

Here are some of the other indexes in the $_SERVER array:

  • Get the user’s IP Address: REMOTE_ADDR
  • Get the hosting server’s name: SERVER_NAME
  • Retrieve the referrer URL: HTTP_REFERER
  • Retrieves the server identification string: SERVER_SOFTWARE
  • Retrieves the pathname of the current running script: SCRIPT_FILENAME
  • Retrieves the current page URL: SERVER_PROTOCOL
  • Retrieves how the script was requested (Did it use “Get” or “Post”): REQUEST_METHOD

If you don’t understand what they do based on the general description given above, do some more research on them, as well as try them out!

$_POST

This predefined variable is very commonly used, and incredibly useful when working with forms. You’ve probably seen this one before if you’ve ever tried to learn PHP.

The $_POST variable is linked to a method in PHP, called “post”, respectively. This method is often used in forms that need to send data to a PHP script. An example of this would be a sign up form: the user enters in data to the form, the form uses the post method to send it to the specified script, and the script can then process the data.

<form method="post" action="phpscript.php">

Easy enough, right? Well in order to carry the input from the form over to the script (in the example above, ‘phpscript.php’), it puts the data in an array, and assigns that array to a variable: $_POST. So, the $_POST variable contains all the data sent through the post method.

To specify the names of the indexes in the $_POST array, we clarify names in the input tags within the form:

<form method="post" action="phpscript.php">
<input name="username" type="text" />

After using the name=”" attribute, we can easily find that data in our $_POST variable array:

$_POST['username']

We have retrieved the data from a form, sent it to a PHP script, and can now work with it inside the PHP script. Using that, we can assign the username to a variable with in our PHP script, manipulate it, or send it to a database.

$_GET

The $_GET variable is very similar to the $_POST variable in that it can work with forms and a PHP method called “get”.

<form method="get" action="phpscript.php">

The difference is that the get method will send information through the URL, like so:

http://example.com/?name=Kayla&website=http://webitect.net

Let’s break that up a bit. We can see the example website: http://example.com. Then, we see a question mark (?). This question mark means that everything following it within this URL is now associated with the form, and contains the variables. We then see “name=Kayla”. This would be if I were to create an input field named “name”, and input “Kayla” for the variable to be passed:

<form method="get" action="thankyou.php">
<input name="name" type="text" />

Next, an ampersand (&) that will connect all the field names and variables. Finally, our second piece of data, named “website” with a value of “http://webitect.net”.

The URL will go to the page where the form wants us to go (the location of the action=”" attribute). In our case, ‘thankyou.php’. It can display a thank you message, or whatever other type of content you’d like to display. In addition, this page can retrieve data with PHP:

$_GET['name']

A better example of $_GET in action is:

<h1>Hello, <?php $_GET['name']; ?>!</h1>

Of course, that’s fairly useless, but you see how it could be used if needed. The point of $_GET is to easily pass information from a form that the user enters, and provide it to the next page. This is helpful for any sort of non-secure information, such as number of items to add to a shopping cart, or posting a website to a database.

You would not, however, ever want to use $_GET for a signup form or anything that uses secure information. Otherwise, important information (like a password) would be sent through the URL, and could be seen by anyone that could view the computer screen.

Conclusion

Hopefully with a more in-depth overview of these three predefined variables, it can get you started in understanding the rest of them. A great place to get started is the PHP Manual itself.

In a future tutorial I really want to go over the $_COOKIE variable, and how one can use cookies to identify users and work with specific users to the programmer’s advantage.

03 Mar 2009

6

jQuery Tutorial: Part III: Parameters

In this tutorial we will be updating the cascading menu we created in jQuery Tutorial: Part II: Cascading Menu. We’ll be adding some CSS to make it look a bit nicer, so hopefully I’ll catch some more interest of the designers!

I’ll also be adding some neat effects that make the tutorial look more like Flash, with the use of parameters. This introduction to parameters will be both helpful with our cascading menu, and with most uses of jQuery.

If you haven’t yet, go read jQuery Tutorial: Part I and jQuery Tutorial: Part II: Cascading Menu.

19 Jan 2009

5

jQuery Tutorial: Part II: Cascading Menu

A cascading menu is a navigation technique that can add a lot of style to any website. Without flash, you can create a flash-like navigation system that is not only fun to look at and use, but is also functional and organized.

We will be creating a very ugly cascading menu for this tutorial, but with a bit of CSS knowledge and creativity, you can make yourself a custom-made and fun menu. Here is what we’ll be making:

Cascading Menu: jQuery.Webitect.net/cascading_menu

22 Dec 2008

5

jQuery Tutorial: Part I

Throughout the recent months of reading other design blogs, I’ve noticed a lot of bloggers talking about, and using, jQuery. I ignored it at first, realizing it wasn’t a language I wanted to learn at this point. However, I’ve now been noticing that everyone’s been using it, and it is almost becoming a necessity for the web designer in today’s world.

So that is why I have decided to start a series of jQuery tutorials myself. It is a pretty straight-forward language, especially if you’re familiar with JavaScript. I’d like to write this series of tutorials from the perspective of a person who has never even heard of jQuery, because I was this person myself just a few months ago. I am, of course, not an expert at this point, but I plan to grow upon the tutorials as I learn more about the language, and the tricks you can do with it.

17 Nov 2008

1

PHP for Beginners: Part II

This is a series of tutorials; here are the others:

This exercise assumes that you either have PHP installed on your computer already or that you have access to a server with PHP support.

Hail, reader! It is gratifying to find that you enjoyed (or at least survived) my first tutorial on the subject of PHP and preferred to continue with the course! I applaud this effort, as it is in the direction of one of the most useful and essential languages to a web developer in the Web 2.0 era.

But we shall hold the accolades until the end. For now, lets get a brief overview of what we’ll be digging into in Part II:

  • Variables and their uses
  • Data types
  • New functions
    • gettype()
    • var_dump()
    • settype()
  • Arithmetic operators
  • Quiz

Variables and their uses

Variables are the underlying dynamic ability of PHP. It’s what allows code to modify the input of a user to suit the purpose of the code’s author. Now, if you’ve taken anything higher than Algebra, you will find this section to be something of a breeze. For those who feel that a review would be beneficial, however, I’ve decided to include a crash course in variables and their operations.

Variables in PHP are much the same in nature as those in math: it is a number, sequence, or operator defined by a letter or a name, such as x or variable_1. In order to define a variable in PHP, you simply type the name of your variable and precede the name by a dollar sign, $. Following this, you will proceed to define the variable with an equal sign similar to below:

$name = "Matt Lidlum";

You will notice that the variable is now defined as Matt Lidlum, which is the argument of the function. The argument, if you’ll remember, is whatever is between either the parentheses or else the quotation marks. And as before, it is important to note that the variable is not defined as “Matt Lidlum”, but simply Matt Lidlum.

Names, however, are not the only things that you can put in here. Numbers can go in as well, as well as operators (which will be discussed later), and various other data types. For now, play around with variables and try using the print function we learned in Part I. An example script is below:

<html>
    <head>
       <title>PHP for Beginners: Part II</title>
    </head>
    <body>
        <?php
            $name = "Matt Lidlum";
            print "$name";
            // This function will print Matt Lidlum
        ?>
   </body>
</html>

Data types

Data types will again call on your mathematical skills in order for you to gain full comprehension. You will find a number of references to math class, so hopefully your motivation to learn PHP and other languages will be motivation enough to keep your head off that comfy sweatshirt.

Back to the matter at hand, there are a total of eight data types used within PHP: six standard and two special. To familiarize yourself with them, please glance over the following tables:

Standard Data Types

PHP Standard Data types

Special Data Types

PHP Special Data Types

As I’m sure you will notice, a number of these data types are already familiar to you. The print function that we discussed within Part I as well as our $name variable both used a string data type. We will not be stopping there, however. Later this lesson you will also touch base on the double, integer, boolean, and NULL data types as well within the functions section.

New functions

As a quick review, you will remember that last lesson we learnt the function print. Within the argument of the print function you could type anything that you would wish to be displayed on your web page. Moving on from this, we will be mastering three new functions, all of which are more used as diagnostic tools to find errors in the code.

Gettype()

We’ll start with the gettype() function. The gettype() function is used in conjunction with the variables within an author’s program. What this function does is display the variable type (string, integer, etc.) on your web page. Simply type the variable name, $ and all, and PHP will return the variable type to you, simple as that. Although this may seem trivial in terms of use, I assure you that it will be built upon later.

Var_dump()

This function is similar to gettype() in its purpose: diagnostics. It does much the same thing, but in a different way. By placing a variable’s name within the argument, PHP will post the variable’s type as well as the variable’s value. Again, the purpose of this function will be built upon later.

Settype()

Settype() is used to change the variable’s type. This function comes in handy when evaluating a user’s input. For example, let’s say that you have created a form based off of PHP and HTML that asks for a user’s input on the company’s customer service. From a drop-down menu, they may choose either good, bad, or impartial. Now, for instance, let’s say that the user chooses good. With settype we can rewrite that variable as true, a boolean data type as you may remember. Thus, in later parts of the code, the true value will initiate other code segments to execute. Another example is a rating system. In a similar question, suppose the user has the option of typing a number 1-5. Suppose now that they type a non-integer value such as 4.2. With settype, the author can automatically change that input to an integer by simply setting the new type of the variable from double to integer. Thus, 4.2 will round down to 4, giving the author exactly what they want. In order for this to be carried out, however, the author must complete the function in the following manner:

<?php
     $VAR_NAME = "VAR_VALUE"
     settype ( $VAR_NAME , NEW_DATA_TYPE)
?>

Now that you have three new functions to add to your print function, it’s time to give them all a shot. Try using variables and messing around with data types as well. Below is an example of PHP and HTML code that I drew up:

<html>
     <head>
         <title>PHP for Beginners: Part II</title>
     </head>
     <body>
         <?php
              $double = "4.5";
              $integer = "6";
              $name = "Matt Lidlum"; //Three separate variables
              print "$name" //Matt Lidlum
              gettype ($integer) //Integer
              gettype ($name) //String
              settype ($double, int) //$double is now an integer
              print "$double" //5
         ?>
     </body>
</html>

Arithmetic Operators

Okay, I know this is getting long and a lot is being thrown at you, but hang in there. What the following discusses is operators; the little things that allow you to manipulate data such as variables or input. Below is a table of arithmetic operators. There are a number of other operators within PHP that are used to do such things as compare data, but we will focus on those in a later tutorial:

Operators

I’m sure you are heaving a huge sigh of relief because as you can tell, these are very simple operators. Simple operators, however, that can have a significant effect on a piece of code. We’ll start off nice and easy with operators. First, lets try them with the print function:

<?php
     print "4 + 5"; //9
?>

Nothing to it, right? This is, as the section is titled, simple arithmetic. Now lets try it out with variables and even changing the variable’s value.

<?php
     $x = "8";
     $x = "$x + 4"; //$x now equals 12
     $y = "2 * $x"; //$y now equals 24
     $z = "$y - $x"; //$z now equals 12
     print "$y - $x is equal to $z!"; //Math is fun!
?>

Here, I defined $x, modified it by adding 4, then defined $y as 2 * $x, and finally made $z equal to $y – $x. Play around with these operators, mixing the print or any other new function among it.

Quiz

Exams help you to retain knowledge that you have just gained, so with that in mind, I’m afraid it’s back to the classroom for everyone. I urge you to not look back at the material or peek ahead at the answer key.

#1: Using the gettype() function on $x when $x = “4.3″ will return…

A.) Boolean
B.) Integer
C.) Double

#2: Using $x from Question 1, using the settype() function on $x, changing it to Integer, will return the value…

A.) True
B.) $x
C.) 4

#3: Which of the following is not an arithmetic operator?

A.) %
B.) &
C.) *

#4: The data type NULL is present when a variable…

A.) Has not been used in a function
B.) Has not been initiated (defined)
C.) Is placed in the gettype() function

#5: Variables are always preceded by…

A.) $
B.) &
C.) %

Answer key: C,C,B,B,A

Conclusion

Well everyone, this tutorial must now come to a close! We’ve made some great strides in part two, and I hope that you’ll stick around for the next article, PHP for Beginners: Part III.

16 Nov 2008

6

PHP For Beginners: Part I

This exercise assumes that you either have PHP installed on your computer already or that you have access to a server with PHP support.

Greetings, eager student! What you are looking at is the first of many tutorials that combine to create an extended resource for PHP beginners. PHP is a staple language within the web design community crucial to the portfolio of any designer. This tutorial and the following series will allow you to read, interpret, modify, and create with PHP, one of the most versatile languages on the net.

Now that we have an idea of what you’re getting into, let’s get a quick overview of what we’ll cover in this tutorial:

  • Identifying PHP tags
  • Writing your first PHP script
  • Combining PHP with HTML
  • Comments within PHP code
  • Quiz

Identifying PHP tags

Web designers have no shortage of languages to use in their work. With CSS, Python, PHP, HTML, and Java crowding the internet with potential, it’s important for the page to know to execute a specific segment of code within a certain language. That’s what tags are for.

If you look in the Source of any web site you’ll see a number of tags. One example is <head>, which is an opening tag used within the HTML language. When the server reads this tag, it knows to execute the following code within the HTML language until it sees the closing tag, which in this case is </head>. The tags used within PHP are very similar to these, and they serve the exact same purpose.

Listed below are these mentioned tags. Look carefully, as they are your first step into the world of PHP programming:

PHP Tags

Pretty basic, right? They all pretty much do the same thing, however your PHP installation will most likely only have the Standard, Short, and Script tags enabled. That’s okay, because Short and Standard are really the only ones that we will be using. Even after you have completed the tutorial, you will see very little deviation from this choice of style.

Writing your first PHP script

Okay, that’s enough background, how about we actually get down to some coding? The script I’m going to introduce you to is called the “Hello world” script. This script has become rather famous as it is almost always the first script given to students when they learn a new language. What we intend to do within this script is simply print the words “Hello world” on your web page. This will be done using the print function.

The print function is exactly what it sounds like: whatever is within the function’s argument, which is whatever is typed after the function, will be printed on the screen for your viewer. See? It doesn’t get much simpler than that. Now that we understand the function, I’m going to give you the piece of code that we will be analyzing. This is because I always have found it easier to understand a language by viewing it and interpreting the coding. So, without further ado, here is the “Hello world” script for PHP:

<?php
     echo "Hello World!";
?>

As I’m sure you will notice first, we have used the tags that I referred to in the previous section. I decided to go with the Standard tags so that you would immediately recognize them for what they are. Next, I’m sure you will notice the print function, and following this the function’s argument. What you might not notice, however, are the apostrophes surrounding Hello world. The reason we are doing this is to specify the function’s argument. Without these apostrophes, the print function would try and display the closing tag ?> instead of simply ending with “world”.

So now that you have this script, I want you to do the following, step-by-step, and you will have successfully made your first code.

  1. Copy and paste the above code into Notepad or another web editor such as FrontPage or Dreamweaver.
  2. Save the file as “NAME_HERE.php”. If in Notepad, make sure you are not saving it as “NAME_HERE.php.txt”.
  3. Upload your file to your server (make sure it supports PHP)
  4. Visit the page, and voila! Congratulations!

Now that you have completed the “Hello world” script, try playing around with the script: modify the print argument, change the tags, or try adding another print function and typing some more.

PHP and HTML are very harmonious, meaning that they work well with each other and allow one other to reach new heights. To integrate PHP into HTML is a very simple process. Pretty much all you have to do is copy and paste! Observe below a simple HTML page with our “Hello world” script embedded within.

<html>
  <head>
      <title>PHP for Beginners: Part I</title>
  </head>
  <body>
      <?php
           print “Hello world”;
      ?>
  </body>
</html>

That’s all there is to it! Explore how this works with your alternate scripts that you created from the previous section.

Comments within PHP Code

Comments are a helpful utility for both the new and professional programmer: they allow the author to write in notes to either themselves or to those who will ultimately use the script in order to assist in the script’s overall interpretation. Whatever is typed within an argument will not be read or executed by the server, making it completely irrelevant to the script’s operation. Below are a few values used to designate the beginning of a comment within the PHP language:

Comments in PHP

Referring back to our PHP and HTML script from the previous section, I decided to add in some helpful comments to you, the reader, so that you can better understand the code:

<html>
   <head>
      <title>PHP for Beginners: Part I</title>
   </head>
   <body>
      <?php
           print “Hello world”;
           // This function will print Hello world

           print “Hello PHP programmer”;
           # This function will print Hello PHP programmer

           /* None of these comments will be seen by the viewer
           unless they look at the source code for the web page*/
      ?>
   </body>
</html>

Try this concept on your own with your own script. Remember, however, that although comments cannot be seen on the page, they are still visible to the clever user. They simply have to view the page source and they will see the layout of your code, comments included. With that in mind, consider this your warning against doing such things as storing passwords or usernames within these comments, as they will become public knowledge very quickly.

Quiz

Exams help you to retain knowledge that you have just gained, so with that in mind, I’m afraid it’s back to the classroom for everyone. I urge you to not look back at the material or peek ahead at the answer key.

#1: The print function will…

A.) Display text within the argument
B.) Command the computer to print the viewed document
C.) Not be recognized within the PHP language

#2: The argument of the print function is…

A.) The preceding text to the function
B.) All text following the function
C.) The text following the function within the apostrophes

#3: Comments can…

A.) Be seen only by the code author
B.) Be seen only by the page viewer
C.) Be seen by both parties

#4: Which of the following is not a correct PHP tag?

A.) <?php
B.) <%
C.) <php
D.) <?

#5: Which of the following is not a correct comment tag?

A.) */Comment here/*
B.) //Comment here
C.) #Comment here

Answer key: A,C,C,C,A

Conclusion

Well everyone, that’s it for now! We’ve laid some solid foundation from which to work off of. So with that in mind, keep practicing, good luck, and read on:

Page 2 of 212