w3resource

PHP Exercises : Print out all the credits for PHP

PHP : Exercise-27 with Solution

Write a PHP script to print out all the credits for PHP.

Sample Solution:

Code:

<!DOCTYPE html>
<html>
<head>
<title>My credits page</title>
</head>
<body>
<?php
// Call the phpcredits function with the specified credits constant
phpcredits(CREDITS_ALL - CREDITS_FULLPAGE);
// This part may contain some additional PHP code specific to your needs
// For example, you can include more PHP code or HTML content here
?>
</body>
</html>

Explanation:

  • HTML Structure:
    • The code starts with a standard HTML structure, including the <!DOCTYPE html> declaration, <html>, <head>, and <body> tags.
  • Document Title:
    • Within the <head> section, the <title> tag sets the title of the webpage to "My credits page".
  • PHP Section:
    • The PHP block (<?php ... ?>) allows PHP code to be executed within the HTML document.
  • Call to phpcredits Function:
    • The function phpcredits(CREDITS_ALL - CREDITS_FULLPAGE) is called:
      • CREDITS_ALL is a constant that represents the total credits available in PHP.
      • CREDITS_FULLPAGE is a constant representing credits that might include a full page.
      • The expression calculates the difference and passes it to the phpcredits function, which displays PHP's credits information on the page.
  • Placeholder for Additional Code:
    • A comment suggests that additional PHP code or HTML content can be included after the phpcredits function call, allowing for further customization of the page.

Output:

View the output in the browser

Flowchart:

Flowchart: Print out all the credits for PHP

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to get the information about the operating system PHP is running on.
Next: Write a PHP script to get the directory path used for temporary files.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php-exercises/php-basic-exercise-27.php