function li( $str )
{
return pipe( "<li> $str </li>" );
}
function h1( $str )
{
return pipe( "<h1> $str </h1>" );
}
function pipe( $args )
{
return function( $fun = NULL ) use( $args )
{
if( !is_callable ( $fun ) ) return $args;
return call_user_func ( $fun, $args );
};
}
echo pipe
( "Text argument" ) // This could be anything, scalar variable, array, object .. etc
( "li" )
( "h1" )
();
//OUTPUT
// <h1> <li> Text argument </li> </h1>
Last active
February 29, 2024 10:22
-
-
Save nezarfadle/b18b5d354d6427b096e0b19a175517f3 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment