Home > Software design >  How do I write this in a single line of code?
How do I write this in a single line of code?

Time:03-25

This is a task from the Codecademy Learn PHP. The task is to print this out to a single line of code.

<?php
    function first()
    {
      return "You did it!\n";
    }
    
    function second()
    {
      return "You're amazing!\n";
    }
    
    function third()
    {
      return "You're a coding hero!\n";
    }
    
    // Write your code below:

Here is what I have:

echo first()   second()   third();

CodePudding user response:

Please look for PHP String Operators The concatenation operator is . so you need:

echo first() . second() . third();

Look live example

  •  Tags:  
  • php
  • Related