Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I write this in a single line of code?

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();

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

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

Look live example

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading