For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > January 2008 > print out variable name as well as its content









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author print out variable name as well as its content
Summercool

2007-10-18, 7:01 pm

I wonder in PHP, can you have a function like

print_debug($foo);

and it will print out:

$foo is:
3

that is, it will print out, most importantly, the variable name, as
well as its content.

Rik Wasmus

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 01:52:42 +0200, Summer <Summerness@gmail.com>
wrote:

> I wonder in PHP, can you have a function like
>
> print_debug($foo);
>
> and it will print out:
>
> $foo is:
> 3
>
> that is, it will print out, most importantly, the variable name, as
> well as its content.
>


No, as it's name should be of utter unimportance.

(Somewhere in this group there's been given a 'solution' for this about a
year ago I think. It involved using debug_backtrace(), fopen()ing the file
and reading/parsing the line indicated in that array. Not anything you
should want to do.)

As said, the variable name should be of no importance. If you're trying to
pinpoint changes in your script you can either use __FILE__ & __LINE__
along with the output, of use the debug_backtrace() mentioned earlier in a
function to output the file & line it was called.
--
Rik Wasmus
Summercool

2007-10-18, 10:03 pm

On Oct 18, 5:03 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Fri, 19 Oct 2007 01:52:42 +0200, Summer <Summern...@gmail.com>
> wrote:
>
>
>
>
[color=darkred]
> No, as it's name should be of utter unimportance.
>
> (Somewhere in this group there's been given a 'solution' for this about a
> year ago I think. It involved using debug_backtrace(), fopen()ing the file
> and reading/parsing the line indicated in that array. Not anything you
> should want to do.)


Coz in C and in Ruby, they are both possible...

in PHP, maybe you can do something like

print_debug("$foo");

and then define

function print_debug($s) {
echo $s, "\n";
print_r(eval($s));
}

?

but is there something that can work better?


Jerry Stuckle

2007-10-18, 10:03 pm

Summer wrote:
> On Oct 18, 5:03 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
>
> Coz in C and in Ruby, they are both possible...
>
> in PHP, maybe you can do something like
>
> print_debug("$foo");
>
> and then define
>
> function print_debug($s) {
> echo $s, "\n";
> print_r(eval($s));
> }
>
> ?
>
> but is there something that can work better?
>
>
>


This is neither C nor Ruby. Don't try to compare them (and, BTW, it's
not part of the C language - it's the debug libraries you're using which
allow it).

If you want the variable's name, just say it!

echo '$foo=' . $foo;


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Summercool

2007-10-18, 10:03 pm

On Oct 18, 5:20 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:

> If you want the variable's name, just say it!
>
> echo '$foo=' . $foo;


sometimes it is more like

echo '$obj->arr[n*size][i-1]' . $obj->arr[n*size][i-1];

so you have to make sure both places are indeed the same expression --
no inconsistency between the two of them. so it would be handy to
just use

print_debug($obj->arr[n*size][i-1]);

and no need to check consistency all the time.


Gary L. Burnore

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 00:16:27 -0000, Summer
<Summerness@gmail.com> wrote:

>On Oct 18, 5:03 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
>
>Coz in C and in Ruby, they are both possible...
>
>in PHP, maybe you can do something like
>
>print_debug("$foo");
>
>and then define
>
>function print_debug($s) {
> echo $s, "\n";
> print_r(eval($s));
>}
>
>?
>
>but is there something that can work better?
>


print_debug("foo",$foo);

Code print_debug accordingly.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Gary L. Burnore

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 00:31:03 -0000, Summer
<Summerness@gmail.com> wrote:

>On Oct 18, 5:20 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
>sometimes it is more like
>
> echo '$obj->arr[n*size][i-1]' . $obj->arr[n*size][i-1];
>
>so you have to make sure both places are indeed the same expression --


If that's too hard for you, perhaps you should consider a job in the
food or hospitality industry.

--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Summercool

2007-10-18, 10:03 pm

On Oct 18, 5:46 pm, Gary L. Burnore <gburn...@databasix.com> wrote:

>
>
> If that's too hard for you, perhaps you should consider a job in the
> food or hospitality industry.


so if PHP or people who are proficient in PHP cannot give a good
solution to this simple thing, i wonder who should work in the food or
hospitality industry.


Rik Wasmus

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 02:58:56 +0200, Summer <Summerness@gmail.com>
wrote:

> On Oct 18, 5:46 pm, Gary L. Burnore <gburn...@databasix.com> wrote:
>
>
> so if PHP or people who are proficient in PHP cannot give a good
> solution to this simple thing, i wonder who should work in the food or
> hospitality industry.


What is the actual 'simple' thing you're trying to solve, as I cannot see
any practical use in production for your proposed feature. Even for
debugging I'd rather know the file/line (which is easily retrievable) then
the variable name, as it sais so much more. Any normal production code
wouldn't need it at all as it should check variables, and on a fail rather
throw errors or exceptions then your debug info.
--
Rik Wasmus
macca

2007-10-18, 10:03 pm

Just an idea, but look up get_defined_vars() in the manual.

e.g.

<?php

// Test Variables

$test_var1 = 1;
$test_var2 = 2;
$another_var = "hello";

/*
get_defined_vars() returns a multidimensional array containing a
list
of all defined variables, be them environment, server or user-
defined
variables
*** WITHIN THE SCOPE get_defined_vars() IS CALLED ***

*/


$arr = get_defined_vars();

foreach ($arr as $key=>$value){

// Shows the different vars you can access
//each one is an array of the vars in that category


switch($key){
case "GLOBALS":
continue 2;
break;
case "_POST":
continue 2;
break;
case "_GET":
continue 2;
break;
case "_COOKIE":
continue 2;
break;
case "_FILES":
continue 2;
break;
}

echo $key ." => ". $value ."<br />";
}


//========================

/*
Outputs

test_var1 => 1
test_var2 => 2
another_var => hello

*/


?>



Regards,

Paul

Jerry Stuckle

2007-10-18, 10:03 pm

Summer wrote:
> On Oct 18, 5:46 pm, Gary L. Burnore <gburn...@databasix.com> wrote:
>
>
> so if PHP or people who are proficient in PHP cannot give a good
> solution to this simple thing, i wonder who should work in the food or
> hospitality industry.
>
>
>


No, if you can't code a simple echo statement than you should be in the
food or hospitality industry.

We told you the answer. If you don't want to accept it, then the food
or hospitality industry sounds like a much better fit for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Michael Fesser

2007-10-18, 10:03 pm

..oO(Summer)

>On Oct 18, 5:46 pm, Gary L. Burnore <gburn...@databasix.com> wrote:
>
>
>so if PHP or people who are proficient in PHP cannot give a good
>solution to this simple thing


Simple? This:

$obj->arr[n*size][i-1]

is not a simple variable name - it's a complex expression! If you pass
that to the function, all the function receives is the result of that
expression, not its source code. If you want that - add it yourself as a
second parameter.

Micha
Summercool

2007-10-18, 10:03 pm

On Oct 18, 6:41 pm, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Summer)
>
>
>
>
>
>
> Simple? This:
>
> $obj->arr[n*size][i-1]



a few other languages I know can make this possible. in the PHP group
I usually hear "don't compare PHP to other languages". or "no, you
don't really need that." oh well, if this is the way it is, so be it.


Jerry Stuckle

2007-10-18, 10:03 pm

Summer wrote:
> On Oct 18, 6:41 pm, Michael Fesser <neti...@gmx.de> wrote:
>
>
> a few other languages I know can make this possible. in the PHP group
> I usually hear "don't compare PHP to other languages". or "no, you
> don't really need that." oh well, if this is the way it is, so be it.
>
>
>


You don't get it, do you? Other languages generally do NOT make this
possible. The debuggers they have may, though.

And there are PHP debuggers, also.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Summercool

2007-10-18, 10:03 pm

On Oct 18, 7:25 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Summer wrote:
>
>
>
>
> You don't get it, do you? Other languages generally do NOT make this
> possible. The debuggers they have may, though.
>
> And there are PHP debuggers, also.



that's not true. The other languages don't need a debugger to make
this possible.

Jerry Stuckle

2007-10-18, 10:03 pm

Summer wrote:
> On Oct 18, 7:25 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
> that's not true. The other languages don't need a debugger to make
> this possible.
>
>


For instance - in C, there is no way to display a variable. It is
strictly the debugging tools which make it work.

Or, I challenge you to show me ANYWHERE in the ANSI C spec that this
should be possible. It doesn't exist.

It is strictly a result of the debugging tools in the compiler.

And I did not say you had to have a debugger. I said debugging tools.
There is a difference!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Gary L. Burnore

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 00:58:56 -0000, Summer
<Summerness@gmail.com> wrote:

>On Oct 18, 5:46 pm, Gary L. Burnore <gburn...@databasix.com> wrote:
>
>
>so if PHP or people who are proficient in PHP cannot give a good
>solution to this simple thing, i wonder who should work in the food or
>hospitality industry.
>

I gave you a simple solution. You don't want it. That's your
problem, not mine. In a real world setting you wouldn't be echoing
the names of your variables unless you want to get hacked. Making
sure both are the same is as simple as copy/paste in either windoze or
Unix and if you can't do that, you should go back to flipping burgers.

--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Gary L. Burnore

2007-10-18, 10:03 pm

On Fri, 19 Oct 2007 02:09:10 -0000, Summer
<Summerness@gmail.com> wrote:

>On Oct 18, 6:41 pm, Michael Fesser <neti...@gmx.de> wrote:
>
>
>a few other languages I know can make this possible.


So go program in other languages.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Gary L. Burnore

2007-10-18, 10:03 pm

On Thu, 18 Oct 2007 22:25:10 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>Summer wrote:
>
>You don't get it, do you? Other languages generally do NOT make this
>possible. The debuggers they have may, though.
>
>And there are PHP debuggers, also.


What'cha wanna bet he leaves the code in debug mode in prod?
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Summercool

2007-10-18, 10:03 pm

On Oct 18, 7:33 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Summer wrote:
>
>
>
> For instance - in C, there is no way to display a variable. It is
> strictly the debugging tools which make it work.
>
> Or, I challenge you to show me ANYWHERE in the ANSI C spec that this
> should be possible. It doesn't exist.
>
> It is strictly a result of the debugging tools in the compiler.
>
> And I did not say you had to have a debugger. I said debugging tools.
> There is a difference!



you can use #define in C to do that. it is in the pre-compiler.

macca

2007-10-18, 10:03 pm

>I wonder in PHP, can you have a function like

> print_debug($foo);


>and it will print out:


>$foo is:
>3



<?php

//============ Function : print_debug( arr result of get_defined_vars,
mixed variable to debug)


function print_debug($defined_vars_array, $debug){

$unset_unwanted =
array("GLOBALS","_POST","_GET","_COOKIE","_FILES");
foreach ($unset_unwanted as $remove){
unset($defined_vars_array[$remove]);
}


while ($element = current($defined_vars_array)) {
if ($element == $debug) {

if (is_array($debug)){
echo '$'.key($defined_vars_array).' = <br />'.
print_r($debug, TRUE) . "<br />";
} else {
echo '$'.key($defined_vars_array).' = '. $debug . "<br />";
}
}
next($defined_vars_array);
}
}


//============= End of Function



// ========================================
=
// somescript.php


// Test Variable
$test_var1 = "This is a test Variable";
$var_test = array(1,2,3);

// debug the variable by calling "print_debug()"

$arr = get_defined_vars();
print_debug($arr,$var_test);


?>

Prints

$var_test =
Array ( [0] => 1 [1] => 2 [2] => 3 )




You get the point. Im off to bed.

Summercool

2007-10-18, 10:03 pm

On Oct 18, 7:45 pm, macca <ptmcna...@googlemail.com> wrote:
>
> <?php
>
> //============ Function : print_debug( arr result of get_defined_vars,
> mixed variable to debug)
>
> function print_debug($defined_vars_array, $debug){
>
> $unset_unwanted =
> array("GLOBALS","_POST","_GET","_COOKIE","_FILES");
> foreach ($unset_unwanted as $remove){
> unset($defined_vars_array[$remove]);
> }
>
> while ($element = current($defined_vars_array)) {
> if ($element == $debug) {
>
> if (is_array($debug)){
> echo '$'.key($defined_vars_array).' = <br />'.
> print_r($debug, TRUE) . "<br />";
> } else {
> echo '$'.key($defined_vars_array).' = '. $debug . "<br />";
> }
> }
> next($defined_vars_array);
> }
>
> }
>
> //============= End of Function
>
> // ========================================
=
> // somescript.php
>
> // Test Variable
> $test_var1 = "This is a test Variable";
> $var_test = array(1,2,3);
>
> // debug the variable by calling "print_debug()"
>
> $arr = get_defined_vars();
> print_debug($arr,$var_test);
>
> ?>
>
> Prints
>
> $var_test =
> Array ( [0] => 1 [1] => 2 [2] => 3 )



The above code doesn't seem to print anything out...
it is mainly to compare values? then what if two variables have the
same content? can it distinguish which is which?


Gary L. Burnore

2007-10-19, 4:00 am

On Fri, 19 Oct 2007 02:58:27 -0000, Summer
<Summerness@gmail.com> wrote:

>On Oct 18, 7:45 pm, macca <ptmcna...@googlemail.com> wrote:
>
>
>The above code doesn't seem to print anything out...


Heh.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
macca

2007-10-19, 4:00 am


> The above code doesn't seem to print anything out...
> it is mainly to compare values? then what if two variables have the
> same content? can it distinguish which is which?


I just wrote this now to give you an idea of how you could do this
thing... if i had two identical values...

$f = 2;
$h = 2;

and I pass it one, say $f (i.e. 2)

$arr = get_defined_vars();
print_debug($arr,$f);

it prints out:

$f = 2
$h = 2


as its the *value* being passed into the function. Seems to compare
values pretty well to me.


The point is, where theres a will theres a way. I came up with this in
a few munutes, i bet there would be some way to refine it given a
little more time and a little less squabbling...

or

just go with Jerry Stuckles method...its a lot easier.

Summercool

2007-10-19, 4:00 am

On Oct 18, 8:38 pm, macca <ptmcna...@googlemail.com> wrote:
>
> just go with Jerry Stuckles method...its a lot easier.



look, i got 20 variables and complicated expressions to print out. it
is for experimentation and not for production. if there is an elegant
solution, fine. the recommendations here seems to be "there is no
need", "why you want to do that?", "if you cannot copy and paste code,
go flip burgers." bravo.




macca

2007-10-19, 8:00 am

Some people just dont appreciate it when you try to help them. Well
I'm not gonna waste any more time on this then...huh.

Jerry Stuckle

2007-10-19, 8:00 am

Summer wrote:
> On Oct 18, 7:33 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
> you can use #define in C to do that. it is in the pre-compiler.
>
>


Yes, it is. But it doesn't produce the output you're looking for. All
that does is create a macro - which expands to exactly what everyone
else was telling you to do.

No difference.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Jerry Stuckle

2007-10-19, 8:00 am

Summer wrote:
> On Oct 18, 8:38 pm, macca <ptmcna...@googlemail.com> wrote:
>
>
> look, i got 20 variables and complicated expressions to print out. it
> is for experimentation and not for production. if there is an elegant
> solution, fine. the recommendations here seems to be "there is no
> need", "why you want to do that?", "if you cannot copy and paste code,
> go flip burgers." bravo.
>
>
>
>
>


The recommendation here is for you to get into the hospitality or
service industry. You're obviously not cut out to be a programmer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Jerry Stuckle

2007-10-19, 8:00 am

Gary L. Burnore wrote:
> On Thu, 18 Oct 2007 22:25:10 -0400, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>
> What'cha wanna bet he leaves the code in debug mode in prod?


No bets here, Gary. :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Kye

2007-10-19, 8:00 am

>> What'cha wanna bet he leaves the code in debug mode in prod?
>
> No bets here, Gary. :-)


For the newbies... Theres a debug mode for code?

--
Yours Sincerely
Kye


Jerry Stuckle

2007-10-19, 8:00 am

Kye wrote:
>
> For the newbies... Theres a debug mode for code?
>


That typically means you've added some code for debugging problems.

There are settings in your php.ini file which should be different
between development and production systems (i.e. display_errors), and
some debug functions. And there are external debuggers.

But there isn't a "debug mode" in the way you're thinking.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Kye

2007-10-19, 8:00 am

> That typically means you've added some code for debugging problems.
>
> There are settings in your php.ini file which should be different between
> development and production systems (i.e. display_errors), and some debug
> functions. And there are external debuggers.
>
> But there isn't a "debug mode" in the way you're thinking.


Would this include the classic things like mysql_error like in the below?

$result = mysql_query($query) or die ('Error in query: $query. '
..mysql_error());

--
Yours Sincerely
Kye


Jerry Stuckle

2007-10-19, 8:00 am

Kye wrote:
>
> Would this include the classic things like mysql_error like in the below?
>
> $result = mysql_query($query) or die ('Error in query: $query. '
> .mysql_error());
>


Yes, I would never use die() or display database error messages in
production code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Gary L. Burnore

2007-10-19, 7:01 pm

On Fri, 19 Oct 2007 08:51:21 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>Kye wrote:
>
>Yes, I would never use die() or display database error messages in
>production code.


Agreed. And while he likely does these things too, I was referring to
his comment about printing variables in C. Leaving preprocsessor
warnings enabled in production.

--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Jerry Stuckle

2007-10-19, 7:01 pm

Gary L. Burnore wrote:
> On Fri, 19 Oct 2007 08:51:21 -0400, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>
> Agreed. And while he likely does these things too, I was referring to
> his comment about printing variables in C. Leaving preprocsessor
> warnings enabled in production.
>


Ah, thanks for the clarification.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Michael Fesser

2007-10-20, 7:01 pm

..oO(Summer)

>On Oct 18, 6:41 pm, Michael Fesser <neti...@gmx.de> wrote:
>
>
>a few other languages I know can make this possible.


Name at least two of them, which allow to print the complex expression
(not only a single variable) passed as an argument to a function.

Micha
kenneth02394832

2007-10-21, 4:12 am

On Oct 19, 4:47 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Summer wrote:
>
>
>
>
>
> Yes, it is. But it doesn't produce the output you're looking for. All
> that does is create a macro - which expands to exactly what everyone
> else was telling you to do.
>
> No difference.



See, Jerry Stuckle, if you are not that good, stop sounding like you
are good. The C preprocessor can do it, by something that's called
Stringification.

http://www.google.com/search?hl=en&...G=Google+Search

Don't know about it, DO YOU? Since you are not as good as me, why
don't you go work for the hospitality or service industry? But sorry,
you are not that hospitable either.


kenneth02394832

2007-10-21, 4:12 am

On Oct 19, 4:49 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Summer wrote:
>
>
> The recommendation here is for you to get into the hospitality or
> service industry. You're obviously not cut out to be a programmer.


If you, Jerry, Stuckle, cannot provide a good solution, that doesn't
mean someone else should go work for a different industry. Maybe you
are smart enough to know that. Maybe not.


kenneth02394832

2007-10-21, 4:12 am

On Oct 20, 9:38 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Summer)
>
>
>
>
>
>
> Name at least two of them, which allow to print the complex expression
> (not only a single variable) passed as an argument to a function.


C and Ruby can both do it.
C is by something that's call Stringification. Google it. For Ruby,
look for the Ruby Forum.


kenneth02394832

2007-10-21, 4:12 am


a search for "Jerry Stuckle" on Google Groups:

http://groups.google.com/groups/sea...s=Search+Groups

the lines

Jerry Stuckle - Fat, Old, Talentless, Unproducing and Stupid

PUNCHING JERRY STUCKLE IN THE FACE

come up quite often...


Jerry Stuckle

2007-10-21, 7:03 pm

kenneth02394832 wrote:
> On Oct 19, 4:47 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
> See, Jerry Stuckle, if you are not that good, stop sounding like you
> are good. The C preprocessor can do it, by something that's called
> Stringification.
>
> http://www.google.com/search?hl=en&...G=Google+Search
>
> Don't know about it, DO YOU? Since you are not as good as me, why
> don't you go work for the hospitality or service industry? But sorry,
> you are not that hospitable either.
>
>


Oh, I know about it, all right. Every one of those examples is a MACRO
- just as I said. But you don't know the difference, do you?

And BTW - I suspect I've been teaching C programming longer than you've
been a programmer. From your updates, probably longer than you've been
alive.

Actually, the service or hospitality industry is beyond your grasp.
Maybe dishwasher would work.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Jerry Stuckle

2007-10-21, 7:03 pm

kenneth02394832 wrote:
> a search for "Jerry Stuckle" on Google Groups:
>
> http://groups.google.com/groups/sea...s=Search+Groups
>
> the lines
>
> Jerry Stuckle - Fat, Old, Talentless, Unproducing and Stupid
>
> PUNCHING JERRY STUCKLE IN THE FACE
>
> come up quite often...
>
>
>


Yep, from trolls like you, Daniel Chandler.

Trolling other groups now? ROFLMAO!

You did catch me the first time. Then I had to check to find it is you
morphing again.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

AnrDaemon

2007-10-21, 7:03 pm

Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, October 21, 2007, 18:12:39,

JS> kenneth02394832 wrote:[color=darkred]

Mmm... Can You both please filter Your quoting?
TIA


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

Michael Fesser

2007-10-21, 7:03 pm

..oO(kenneth02394832)

>On Oct 20, 9:38 am, Michael Fesser <neti...@gmx.de> wrote:
>
>
>C and Ruby can both do it.
>C is by something that's call Stringification.


It's done by the preprocessor for replacing arguments passed to a
_macro_. But a macro is not a function, which is what we're talking
about here.

Micha
Gary L. Burnore

2007-10-21, 7:03 pm

On Sun, 21 Oct 2007 18:30:51 +0400, AnrDaemon <anrdaemon@freemail.ru>
wrote:

>Greetings, Jerry Stuckle.
>In reply to Your message dated Sunday, October 21, 2007, 18:12:39,
>
>JS> kenneth02394832 wrote:
>
>Mmm...


dip.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
========================================
===================================
Summercool

2007-10-24, 4:01 am

On Oct 21, 7:12 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
> Oh, I know about it, all right. Every one of those examples is a MACRO
> - just as I said. But you don't know the difference, do you?


You thought it was impossible. And now you are saying "Macro blah
blah blah"? What a loser.

Jerry Stuckle - Fat, Old, Talentless, Unproducing and Stupid

is indeed true.


the_case_continues@yahoo.co.uk

2007-12-05, 7:02 pm

This simple solution is from 2003:

http://www.devnetwork.net/forums/viewtopic.php?p=65222

It works.
Summercool

2008-01-24, 8:08 am

On Dec 5 2007, 10:06=A0am, the_case_contin...@yahoo.co.uk wrote:
> This simple solution is from 2003:
>
> http://www.devnetwork.net/forums/vi...c.php?p=3D65222
>
> It works.


for people following this thread. the URL seems to be updated to

http://forums.devnetwork.net/viewtopic.php?p=3D65222

and here is the content:

<?php
function print_var($varname)
{
global ${$varname};
echo $varname, ': ', ${$varname};
}

$foo =3D (int)123;
print_var('foo');
?>




Summercool

2008-01-24, 8:08 am

On Jan 24, 2:23=A0am, Summer <Summern...@gmail.com> wrote:
>
> for people following this thread. =A0the URL seems to be updated to
>
> http://forums.devnetwork.net/viewtopic.php?p=3D65222


and it seems to work for some cases but not all:

<?
function print_var($varname)
{
global ${$varname};
echo $varname, ': ';
print_r(${$varname});
echo "\n";
}

$foo =3D 123;
print_var('foo');
$bar =3D 123;
print_var("bar");
$far =3D array(1,3,5);
print_var("far");
print_var('far[1]');

?>

$ php try.php
foo: 123
bar: 123
far: Array
(
[0] =3D> 1
[1] =3D> 3
[2] =3D> 5
)

far[1]:

so the last one didn't work



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com