Computer

PHP/Oracle Development


Syllabus
Schedule
Reading
Discussion
Project
Test
Resource
Tip

Class Time: Week 3
(
Functions)

This week, we are focusing our efforts on functions. To avoid confusion, there is one major issue that I did not address in Class Notes 5. That is the difference between "pass by value" and "pass by reference." We will use this forum to ask everyone to study and research so that we can gain a good understand on the two concepts.

 

Discussion Topic:

We have the following PHP code:

----

<?php
// Declare variable.
$var = "Oracle";

// Print actual parameter value before function.
print "Before function \$var [".$var."]<br>";

// Call the user-defined function.
print_string($var);

// Print actual parameter value after function.
print "After function \$var [".$var."]";

// Define function that prints an input parameter as a string.
function print_string($var)
{
// Print the local variable with a text literal.
$var = "Access";

// Print actual parameter value.
print "Inside function \$var [".$var."]<br>";
}
?>

------


 

Questions:

  1. What is the output from the above code?

  2. If we change the function definition as follows?

    function print_string(&$var)

    Everything else in the above code remain the same. What is the output from the above code? Please provide explanations on why?

 

 

Online Discussion Policy:

1. Discussion Board is the main vehicle for the entire class to have close interactions.  Students are required to actively participate in all discussions.  The total weight of discussion accounts for 25% of the total grade (15% for Class Time Discussion and 10% for Weekly Geeks Corner).

2. Students are supposed to complete discussions by the due date.  Due date policy applies to both discussion, definitely.

3. There will be two major categories of questions to be discussed: instructor-posted, and student-posted.  Students are required to participate in BOTH discussions.

4. Weekly Discussion (Class Time): The instructor-posted questions are intended to facilitate and verify your understanding of the related subject.  The following guidelines will be followed for evaluation.  Each question will have a total of 100 achievable points for the week.

a. Responsiveness to the right question (hit the point). (15 points)

b. Clarity of response. (10 points)

c. Completeness of response. (15 points)

d. Support for response from reading or other resources. (15 points)

e. Correct sentence structure and spelling.  Please use complete sentences and correct English grammar/spelling. By the way, I do not like the language used in text message such as "how r u?"(10 points)

f. Professionalism or Netiquette (no bad languages).

g. Reply to at least one other students' discussions.  (10 points)

h. You have to read at least 50% of the messages posted. (10 points)

i. Do not use such expressions as "I do not know." Offer your insight or suggestions.

j. Have a sense of humor (5 points)

k. Timely bonus: The first 5 students responding to the posted question will receive bonus points in the scale of 10, 8, 6, 4, 2. The first one will receive 10, and the fifth one will have 2 points.