How can the echo output from the second function be accessed and displayed in the first function in PHP?

To access and display the echo output from the second function in the first function in PHP, you can capture the output of the second function using output buffering. This way, you can store the echoed output in a variable and then return or display it in the first function.

<?php

function secondFunction() {
    // Output something using echo
    echo "Hello from second function!";
}

function firstFunction() {
    ob_start(); // Start output buffering
    secondFunction(); // Call the second function
    $output = ob_get_clean(); // Get the output of the second function
    echo $output; // Display the output in the first function
}

firstFunction(); // Call the first function

?>