E
E
eps-game2020-05-10 11:29:02
PHP
eps-game, 2020-05-10 11:29:02

How to ignore PHP function output?

There is a depressed function

<?php

function depressed () {
?>

<h1>Hello, <?php other_function(); ?></h1>

<?php
}


It contains HTML code that can be placed in it in the manner described above.
Is it possible to call the depressed function so that it executes (including other_function ), but does not display the result on the screen?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Morev, 2020-05-10
@eps-game

ob_start();
depressed();
ob_end_clean();

F
FanatPHP, 2020-05-10
@FanatPHP

For a change, you can stop shit-coding and start doing the right thing right away instead of putting on crutches later.
For example, make sure that logic and output are separated. If you need to perform some action - this is one function, if you need to display some data - then another.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question