Jump to content

Recommended Posts

Ok, so here's the story.

 

I have created a very large program. This program has grown way beyond a one person project. I want to run all variables through a validate function before it is sent to the user. The problem is the program is so large, that it would take me a very long time to do that. Now I know one option is to make a function like "function output(value) { // do validate and echo }". But, that would mean I have to go through and modify all the echo statements in my code. That too, would take a very long time.

 

So, what I'd like to know, is if there is a way to append a function to the echo construct? Kind of like register_shutdown_function, only something like register_construct_function(echo, MyFunction)...

 

Or if anyone has another way, that would be awesome.

Link to comment
https://forums.phpfreaks.com/topic/203297-modify-php-echo-command/
Share on other sites

You could wrap your entire application so that all output would be caught in a buffer. Just set the auto_prepend_file directive within your php.ini to point to a file containing....

 

<?php ob_start(); ?>

 

Then use the auto_append_file directive to point to another script that captures the output into a string, you can then do whatever needs doing to the output all in one place.

 

<?php

$output = ob_get_contents();

// validate $output here

echo $output;

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.