answersLogoWhite

0

AllQ&AStudy Guides
Best answer

printf ("square of %d is %d\n", $n, $n*$n);

This answer is:
Related answers

printf ("square of %d is %d\n", $n, $n*$n);

View page

You cannot, you need PHP

Here is what I came up with, for you:

<?php

$to = 'nobody@example.com';

$subject = 'the subject';

$message = 'hello';

$headers = 'From: webmaster@example.com' . "\r\n" .

'Reply-To: webmaster@example.com' . "\r\n" .

'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

View page

PHP is processed on the server side, not the browser side. This means that any browser (including Safari), never actually opens a PHP file (unless it's loaded locally rather than served from the web, in which case it would be read as a plain text file). Instead, it receives the output from the server that contains the PHP file.

For example, if you have a PHP file that reads like this:

<?php echo "<html>\n<body>\nI am the lizard queen!\n</body>\n</html>"; ?>

Safari would actually see it as plain HTML, like this:

<html>

<body>

I am the lizard queen!

</body>

</html>

It would never actually see the PHP code itself.

View page

The easiest way to do this is with an exclusive-or operator, represented by the ^ symbol.

For example, 10 ^ 15 = 1010b ^ 1111b = 0101b

Here's a quick example script that would make use of it:

#!/usr/bin/php

<?php

if($argc != 2){ echo "gimme a number!\n"; exit;}

$x = $argv[1];

for($n = 0; 1 << $n <= $x; $n++);

$y = $x ^ ((1 << $n) - 1);

echo "The binary complement of $x = %y\n";

View page

for($rval = $n = intval($_GET['number']); $n > 2; $n--) $rval *= $n - 1;
echo $rval;

View page
Featured study guide
📓
See all Study Guides
✍️
Create a Study Guide
Search results