Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7768 > unrolled thread
| Started by | C <wrong.address.1@gmail.com> |
|---|---|
| First post | 2012-12-11 07:59 -0800 |
| Last post | 2012-12-12 08:18 +0200 |
| Articles | 15 — 11 participants |
Back to article view | Back to comp.lang.php
Printing out or displaying for debugging C <wrong.address.1@gmail.com> - 2012-12-11 07:59 -0800
Re: Printing out or displaying for debugging The Natural Philosopher <tnp@invalid.invalid> - 2012-12-11 16:05 +0000
Re: Printing out or displaying for debugging wrong.address.1@gmail.com - 2012-12-11 08:59 -0800
Re: Printing out or displaying for debugging Denis McMahon <denismfmcmahon@gmail.com> - 2012-12-11 20:39 +0000
Re: Printing out or displaying for debugging Salvatore <sal@yojimbo.hack.invalid> - 2012-12-11 16:24 +0000
Re: Printing out or displaying for debugging Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-12-11 10:16 -0700
Re: Printing out or displaying for debugging The Natural Philosopher <tnp@invalid.invalid> - 2012-12-11 18:18 +0000
Re: Printing out or displaying for debugging Shake <QUITAESTO@QUITAESTO.NOES> - 2012-12-11 18:31 +0100
Re: Printing out or displaying for debugging Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-11 12:32 -0500
Re: Printing out or displaying for debugging Robert Heller <heller@deepsoft.com> - 2012-12-11 13:04 -0600
Re: Printing out or displaying for debugging Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-12-11 10:52 -0700
Re: Printing out or displaying for debugging Robert Heller <heller@deepsoft.com> - 2012-12-11 13:04 -0600
Re: Printing out or displaying for debugging wrong.address.1@gmail.com - 2012-12-13 05:29 -0800
Re: Printing out or displaying for debugging SwissCheese <swisscheese@cfl.rr.com> - 2012-12-11 19:14 -0500
Re: Printing out or displaying for debugging Simon <bad@example.com> - 2012-12-12 08:18 +0200
| From | C <wrong.address.1@gmail.com> |
|---|---|
| Date | 2012-12-11 07:59 -0800 |
| Subject | Printing out or displaying for debugging |
| Message-ID | <311acfc8-1a24-4cd6-93aa-3bfc1407e840@b16g2000vbh.googlegroups.com> |
What is a good way to see the values of a few variables for debugging? I cannot debug locally. I have to put the code on the server in the normal Internet site (which does not receive a lot of human visitors), so it would not hurt to display the values of some variables for a few minutes while I am debugging.
[toc] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-12-11 16:05 +0000 |
| Message-ID | <ka7ljs$23l$1@news.albasani.net> |
| In reply to | #7768 |
On 11/12/12 15:59, C wrote: > What is a good way to see the values of a few variables for debugging? > I cannot debug locally. I have to put the code on the server in the > normal Internet site (which does not receive a lot of human visitors), > so it would not hurt to display the values of some variables for a few > minutes while I am debugging. > I would write a php function that does three things. (i) checks to see if the browser remote IP address is you, and if it isn't, does nothing - that lets all of your other users off the hook. (ii) adds any error and debugging messages to a big chunk of memory. (iii) RIGHT at the end of you page, calls the function again to *display* the buffer contents in a <div> that overlays everything. An alternative is to create a debug notice area in some empty bit of real estate. -- Ineptocracy (in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[toc] | [prev] | [next] | [standalone]
| From | wrong.address.1@gmail.com |
|---|---|
| Date | 2012-12-11 08:59 -0800 |
| Message-ID | <d30a2ab8-27af-4d77-916c-420f0a645ad3@googlegroups.com> |
| In reply to | #7769 |
I am just a beginner, so I will need help with the actual commands I should use, not necessarily the whole code, but the commands which I should learn to use. Thanks. On Tuesday, December 11, 2012 6:05:19 PM UTC+2, The Natural Philosopher wrote: > On 11/12/12 15:59, C wrote: > > > What is a good way to see the values of a few variables for debugging? > > > I cannot debug locally. I have to put the code on the server in the > > > normal Internet site (which does not receive a lot of human visitors), > > > so it would not hurt to display the values of some variables for a few > > > minutes while I am debugging. > > > > > I would write a php function that does three things. > > (i) checks to see if the browser remote IP address is you, and if it > > isn't, does nothing - that lets all of your other users off the hook. > > (ii) adds any error and debugging messages to a big chunk of memory. > > (iii) RIGHT at the end of you page, calls the function again to > > *display* the buffer contents in a <div> that overlays everything. > > > > An alternative is to create a debug notice area in some empty bit of > > real estate. > > > > > > > > -- > > Ineptocracy > > > > (in-ep-toc’-ra-cy) – a system of government where the least capable to > > lead are elected by the least capable of producing, and where the > > members of society least likely to sustain themselves or succeed, are > > rewarded with goods and services paid for by the confiscated wealth of a > > diminishing number of producers.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-12-11 20:39 +0000 |
| Message-ID | <ka85m6$a4r$1@dont-email.me> |
| In reply to | #7772 |
On Tue, 11 Dec 2012 08:59:32 -0800, wrong.address.1 wrote: > I am just a beginner Indeed you are. Lesson 1a. In usenet, by convention and etiquette of almost 30 years (usenet is first defined in RFC 850 dated 1983), the reply goes underneath the quoted text, not above it. Lesson 1b. This is actually a usenet newsgroup, regardless of the form and mechanisms by which it is presented to you. Please respect usenet convention and etiquette here. Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | Salvatore <sal@yojimbo.hack.invalid> |
|---|---|
| Date | 2012-12-11 16:24 +0000 |
| Message-ID | <ka7mo6$2ffq$1@yojimbo.hack> |
| In reply to | #7768 |
On 2012-12-11, C <wrong.address.1@gmail.com> wrote: > What is a good way to see the values of a few variables for debugging? var_export() works great as long as you set the second parameter to true. -- Blah blah bleh... GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
[toc] | [prev] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2012-12-11 10:16 -0700 |
| Message-ID | <ka7ppf$oov$1@dont-email.me> |
| In reply to | #7768 |
C wrote:
> What is a good way to see the values of a few variables for debugging?
> I cannot debug locally. I have to put the code on the server in the
> normal Internet site (which does not receive a lot of human visitors),
> so it would not hurt to display the values of some variables for a few
> minutes while I am debugging.
What I typically do is make a copy of the
webpage and call it TestSomething.php. You
can then do whatever you want with the
knowledge that nobody else will visit the
page.
You can then display variables using:
<?php echo $a_variable; ?>
--
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-12-11 18:18 +0000 |
| Message-ID | <ka7tdm$j05$1@news.albasani.net> |
| In reply to | #7773 |
On 11/12/12 17:16, Martin Leese wrote: > C wrote: >> What is a good way to see the values of a few variables for debugging? >> I cannot debug locally. I have to put the code on the server in the >> normal Internet site (which does not receive a lot of human visitors), >> so it would not hurt to display the values of some variables for a few >> minutes while I am debugging. > > What I typically do is make a copy of the > webpage and call it TestSomething.php. You > can then do whatever you want with the > knowledge that nobody else will visit the > page. > > You can then display variables using: > <?php echo $a_variable; ?> > sound advice. -- Ineptocracy (in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[toc] | [prev] | [next] | [standalone]
| From | Shake <QUITAESTO@QUITAESTO.NOES> |
|---|---|
| Date | 2012-12-11 18:31 +0100 |
| Message-ID | <ka7qm8$v1g$1@dont-email.me> |
| In reply to | #7768 |
There are lots of ways.
First:
use print_r
use var_dump
Check de manual for these useful tools.
Second:
To show info in screen:
- You can check the IP-
- You can check user logged of type Admin.
- You can pass (and check) some data by GET
An usefull way is (short and simple version):
Use a function with global var (or better static), something like
function DebugInfo($text, $bWeb = true) {
global $DebugInfoTxT;
$DebugInfoTxT .= "$text\n";
if($bWeb) $DebugInfoTxT .= '<br />';
}
You can call this function to "save" debug info.
<?php
if($something) {
DebugInfo('something is true');
}
DebugInfo("Value $something");
?>
And at the end, a function that "echoes" everything:
function showDebug() {
global $DebugInfoTxT;
//check here things, like UP, User, or some get... for example
if(isset($_GET['debug'])&&$_GET['debug']=='ejd7d7ehebd') {
echo "<div id='debug'>$DebugInfoTxT</div>\n";
}
}
With some CSS, and Some Javascript, you can make the "debug" DIV easy to
see, hide...
Encapsulate this in a Class...
regards
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-12-11 12:32 -0500 |
| Message-ID | <ka7qnf$vao$1@dont-email.me> |
| In reply to | #7768 |
On 12/11/2012 10:59 AM, C wrote: > What is a good way to see the values of a few variables for debugging? > I cannot debug locally. I have to put the code on the server in the > normal Internet site (which does not receive a lot of human visitors), > so it would not hurt to display the values of some variables for a few > minutes while I am debugging. > You should ALWAYS have a development environment separate from (but very similar to) your live system. NEVER upload untested/undebugged code to a live system, no matter how few visitors it gets! -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Robert Heller <heller@deepsoft.com> |
|---|---|
| Date | 2012-12-11 13:04 -0600 |
| Message-ID | <38WdnQIX_fEhHlrNnZ2dnUVZ_gidnZ2d@giganews.com> |
| In reply to | #7775 |
At Tue, 11 Dec 2012 12:32:23 -0500 Jerry Stuckle <jstucklex@attglobal.net> wrote:
>
> On 12/11/2012 10:59 AM, C wrote:
> > What is a good way to see the values of a few variables for debugging?
> > I cannot debug locally. I have to put the code on the server in the
> > normal Internet site (which does not receive a lot of human visitors),
> > so it would not hurt to display the values of some variables for a few
> > minutes while I am debugging.
> >
>
> You should ALWAYS have a development environment separate from (but very
> similar to) your live system. NEVER upload untested/undebugged code to
> a live system, no matter how few visitors it gets!
>
+1
It is dead trivial to install a basic simple LAMP server either on a
random spare PC, hard drive partition, or (if your machine is new
enough) on a bootable thumb drive. Or you can install a VM system
(like VirtualBox) and install a LAMP server as a virtual machine.
(It is also possible to install a WAMP server if you really must.)
--
Robert Heller -- 978-544-6933 / heller@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
[toc] | [prev] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2012-12-11 10:52 -0700 |
| Message-ID | <ka7rt5$7ao$1@dont-email.me> |
| In reply to | #7768 |
C wrote:
> What is a good way to see the values of a few variables for debugging?
> I cannot debug locally. I have to put the code on the server in the
> normal Internet site
...
I debug locally using the PHP Command Line
Interpreter (CLI). In a Windows BAT file, I
use:
php -n -f "%inputFile%" > "%outputFile%"
--
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | Robert Heller <heller@deepsoft.com> |
|---|---|
| Date | 2012-12-11 13:04 -0600 |
| Message-ID | <I9mdnRLmwcMhHlrNnZ2dnUVZ_qqdnZ2d@giganews.com> |
| In reply to | #7768 |
At Tue, 11 Dec 2012 07:59:47 -0800 (PST) C <wrong.address.1@gmail.com> wrote:
>
> What is a good way to see the values of a few variables for debugging?
> I cannot debug locally. I have to put the code on the server in the
> normal Internet site (which does not receive a lot of human visitors),
> so it would not hurt to display the values of some variables for a few
> minutes while I am debugging.
echo '<!-- var1 = '.$var1.' -->';
This creates an HTML comment. Nothing is actually displayed in your (or
anyone else's) browser. BUT if you <right click>=>Show Page Source, you
can see the HTML code, including the HTML comments.
>
--
Robert Heller -- 978-544-6933 / heller@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
[toc] | [prev] | [next] | [standalone]
| From | wrong.address.1@gmail.com |
|---|---|
| Date | 2012-12-13 05:29 -0800 |
| Message-ID | <099f782e-8c38-4ab0-b95b-1d6137c2aadc@googlegroups.com> |
| In reply to | #7778 |
On Tuesday, December 11, 2012 9:04:28 PM UTC+2, Robert Heller wrote: > At Tue, 11 Dec 2012 07:59:47 -0800 (PST) C <wrong.address.1@gmail.com> wrote: > > What is a good way to see the values of a few variables for debugging? > I cannot debug locally. I have to put the code on the server in the > normal Internet site (which does not receive a lot of human visitors), > so it would not hurt to display the values of some variables for a few > minutes while I am debugging. echo '<!-- var1 = '.$var1.' -->'; This creates an HTML comment. Nothing is actually displayed in your (or anyone else's) browser. BUT if you <right click>=>Show Page Source, you can see the HTML code, including the HTML comments. > -- Robert Heller -- 978-544-6933 / heller@deepsoft.com Deepwoods Software -- http://www.deepsoft.com/ () ascii ribbon campaign -- against html e-mail /\ www.asciiribbon.org -- against proprietary attachments I think this was the best way. I did this and found the error with little effort. Thanks very much.
[toc] | [prev] | [next] | [standalone]
| From | SwissCheese <swisscheese@cfl.rr.com> |
|---|---|
| Date | 2012-12-11 19:14 -0500 |
| Message-ID | <ka8i8n$tnf$1@dont-email.me> |
| In reply to | #7768 |
On 12/11/2012 10:59 AM, C wrote: > What is a good way to see the values of a few variables for debugging? > I cannot debug locally. I have to put the code on the server in the > normal Internet site (which does not receive a lot of human visitors), > so it would not hurt to display the values of some variables for a few > minutes while I am debugging. > Another method is to throw them into comments within the output HTML, ie: echo "<!--"; vardump($var) printr($var) etc... echo "-->"; then comment out/remove that code when done. Just 'View Source...' to see it. -- Norman Registered Linux user #461062 -Have you been to www.php.net yet?-
[toc] | [prev] | [next] | [standalone]
| From | Simon <bad@example.com> |
|---|---|
| Date | 2012-12-12 08:18 +0200 |
| Message-ID | <aiqlthF95g5U1@mid.individual.net> |
| In reply to | #7781 |
> > echo "<!--"; > vardump($var) > printr($var) > etc... > echo "-->"; > > then comment out/remove that code when done. Just 'View Source...' to > see it. Unless $var contains html code, (maybe what the OP is trying to debug in the first place), and that could end up causing a whole lot of mess, (making it more difficult to debug). A local site, is a far better option. I prefer to install php+Apache manually but that's just a mater of choice. Otherwise, a carbon copy of the page with the debug code on another page is a better/safe/prettier? option. Simon
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web