How to define a new global function?

How to define a new global function?

am 17.08.2007 19:00:12 von Ming

Very frequently, I need to use codes like this to see output clearly:

$a=print_r($var,true);
echo "

$a
";

How can convert this piece of code to a global function (for example:
echopre) in Php so that I can use echopre($data) anywhere in php
program (in my server)?

Thanks,

Re: How to define a new global function?

am 17.08.2007 19:03:10 von luiheidsgoeroe

On Fri, 17 Aug 2007 19:00:12 +0200, Ming wrote:

> Very frequently, I need to use codes like this to see output clearly:
>
> $a=3Dprint_r($var,true);
> echo "

$a
";
>
> How can convert this piece of code to a global function (for example:
> echopre) in Php so that I can use echopre($data) anywhere in php
> program (in my server)?

Define the function somewhere? Functions are always in scope, there are =
no =

'local' or 'global' functions. So just put this code somewhere in the =

beginning/in a functions-include file:
function echopre($a){
$a=3Dprint_r($var,true);
echo "
$a
";
}
?>
-- =

Rik Wasmus

Re: How to define a new global function?

am 17.08.2007 19:05:31 von Ming

On Aug 17, 10:03 am, Rik wrote:
> On Fri, 17 Aug 2007 19:00:12 +0200, Ming wrote:
> > Very frequently, I need to use codes like this to see output clearly:
>
> > $a=print_r($var,true);
> > echo "

$a
";
>
> > How can convert this piece of code to a global function (for example:
> > echopre) in Php so that I can use echopre($data) anywhere in php
> > program (in my server)?
>
> Define the function somewhere? Functions are always in scope, there are no
> 'local' or 'global' functions. So just put this code somewhere in the
> beginning/in a functions-include file:
> > function echopre($a){
> $a=print_r($var,true);
> echo "
$a
";}
>
> ?>
> --
> Rik Wasmus

Thanks Rik.

I want to make it as a stand function come with php. i.e.: I want to
make it anywhere I can use echo.

Re: How to define a new global function?

am 17.08.2007 19:12:31 von luiheidsgoeroe

On Fri, 17 Aug 2007 19:05:31 +0200, Ming wrote:

> On Aug 17, 10:03 am, Rik wrote:
>> On Fri, 17 Aug 2007 19:00:12 +0200, Ming wrote:=

>> > Very frequently, I need to use codes like this to see output clearl=
y:
>>
>> > $a=3Dprint_r($var,true);
>> > echo "

$a
";
>>
>> > How can convert this piece of code to a global function (for exampl=
e:
>> > echopre) in Php so that I can use echopre($data) anywhere in php
>> > program (in my server)?
>>
>> Define the function somewhere? Functions are always in scope, there a=
re =

>> no
>> 'local' or 'global' functions. So just put this code somewhere in the=

>> beginning/in a functions-include file:
>> >> function echopre($a){
>> $a=3Dprint_r($var,true);
>> echo "
$a
";}
>>
>> ?>
>> --

Don't quote signatures please.

> I want to make it as a stand function come with php. i.e.: I want to
> make it anywhere I can use echo.

Hmm, I'm not sure I understand. You want it to be a function that's =

automatically available in every script run on the server, without =

calling/defining it in the script? You could set an auto_prepend_file in=
=

php.ini with the function definition.
-- =

Rik Wasmus

Re: How to define a new global function?

am 17.08.2007 19:21:33 von Ming

On Aug 17, 10:12 am, Rik wrote:
> On Fri, 17 Aug 2007 19:05:31 +0200, Ming wrote:
> > On Aug 17, 10:03 am, Rik wrote:
> >> On Fri, 17 Aug 2007 19:00:12 +0200, Ming wrote:
> >> > Very frequently, I need to use codes like this to see output clearly:
>
> >> > $a=print_r($var,true);
> >> > echo "

$a
";
>
> >> > How can convert this piece of code to a global function (for example:
> >> > echopre) in Php so that I can use echopre($data) anywhere in php
> >> > program (in my server)?
>
> >> Define the function somewhere? Functions are always in scope, there are
> >> no
> >> 'local' or 'global' functions. So just put this code somewhere in the
> >> beginning/in a functions-include file:
> >> > >> function echopre($a){
> >> $a=print_r($var,true);
> >> echo "
$a
";}
>
> >> ?>
> >> --
>
> Don't quote signatures please.
>
> > I want to make it as a stand function come with php. i.e.: I want to
> > make it anywhere I can use echo.
>
> Hmm, I'm not sure I understand. You want it to be a function that's
> automatically available in every script run on the server, without
> calling/defining it in the script? You could set an auto_prepend_file in
> php.ini with the function definition.
> --
> Rik Wasmus

Terrific help.

Many thanks!