Practice Makes Perfect


#1

Functions Part II, Practice Makes Perfect

Why does my code output/print a 1 at the end?



<html>
	<head>
		<title></title>
	</head>
	<body>
      <p>
        <?php
      function aboutMe($name, $age) {
        echo print "Hello! My name is " . $name . " and I am " . $age . " years old.";
      }
      aboutMe("brandon", 28);
        ?>
      </p>
    </body>
</html>

My Code outputs/prints a 1 to editor box:
Hello! My name is brandon and I am 28 years old.1


#2

echo and print in the same statement does not look right.


#3

Picking up where @mtf guided you, combining those instructions does this:

  1. Concatenate the string.
  2. Then print the result to the browser.
  3. Then echo the return value of print, which is 1 (see the manual here).

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.