Science Daily: Jupiter
- Heart of Jovian moon's volcanic rage December 13, 2024
- NASA's Hubble celebrates decade of tracking outer planets December 9, 2024
html_vardump: printf on steroids
html_vardump()
So how exactly do you debug you PHP scripts? I’m not expert on this, but I find it inconvenient trying to debug an interpreted file living in a daemon process. I mean, with a real program, you can attach to it with something like GDB. But with PHP, I find myself resorting back to the old printf school of debugging.
html_vardump() is a slight improvement for dumping out data structures. It is more-or-less the same as PHP’s vardump but with two modifications. First, all of the output is run through htmlentities() and addcslashes() so that everything will print in a web page. Second, you can decide whether or not you want html_vardump() to print everything or simply return a string which can be printed wherever you like. Not printing is the default.
Here’s a simple example of using html_vardump():
$image = "mypic.jpeg"; $exif = read_exif_data ($image); $vardump = html_vardump ($exif, 0); echo $vardump;
And here is what the output from a real picture looks like:
array(64) =>
[FileName] =>
string(17) =>
"20010601-0001.jpg"
[FileDateTime] =>
integer(991436204)
[FileSize] =>
integer(307155)
[FileType] =>
integer(2)
[MimeType] =>
string(10) =>
"image/jpeg"
[SectionsFound] =>
string(50) =>
"ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP, MAKERNOTE"
[COMPUTED] =>
array(11) =>
[html] =>
string(25) =>
"width="1280" height="960""
[Height] =>
integer(960)
[Width] =>
integer(1280)
[IsColor] =>
integer(1)
[ByteOrderMotorola] =>
integer(0)
[CCDWidth] =>
string(3) =>
"5mm"
[ExposureTime] =>
string(14) =>
"0.016 s (1/64)"
[ApertureFNumber] =>
string(5) =>
"f/3.6"
[Copyright] =>
string(10) =>
" "
[Thumbnail.FileType] =>
integer(2)
[Thumbnail.MimeType] =>
string(10) =>
"image/jpeg"
[Make] =>
string(8) =>
"FUJIFILM"
[Model] =>
string(15) =>
"FinePix1400Zoom"
[Orientation] =>
integer(1)
[XResolution] =>
string(4) =>
"72/1"
[YResolution] =>
string(4) =>
"72/1"
[ResolutionUnit] =>
integer(2)
[Software] =>
string(38) =>
"Digital Camera FinePix1400Zoom Ver1.00"
[DateTime] =>
string(19) =>
"2001:06:01 17:56:44"
[YCbCrPositioning] =>
integer(2)
[Copyright] =>
string(10) =>
" "
[Exif_IFD_Pointer] =>
integer(276)
[THUMBNAIL] =>
array(8) =>
[Compression] =>
integer(6)
[Orientation] =>
integer(1)
[XResolution] =>
string(4) =>
"72/1"
[YResolution] =>
string(4) =>
"72/1"
[ResolutionUnit] =>
integer(2)
[JPEGInterchangeFormat] =>
integer(1100)
[JPEGInterchangeFormatLength] =>
integer(5700)
[YCbCrPositioning] =>
integer(2)
[FNumber] =>
string(5) =>
"36/10"
[ExposureProgram] =>
integer(2)
[ISOSpeedRatings] =>
integer(125)
[ExifVersion] =>
string(4) =>
"0210"
[DateTimeOriginal] =>
string(19) =>
"2001:06:01 17:56:44"
[DateTimeDigitized] =>
string(19) =>
"2001:06:01 17:56:44"
[ComponentsConfiguration] =>
string(4) =>
"\001\002\003\000"
[CompressedBitsPerPixel] =>
string(3) =>
"2/1"
[ShutterSpeedValue] =>
string(5) =>
"60/10"
[ApertureValue] =>
string(5) =>
"37/10"
[BrightnessValue] =>
string(6) =>
"-13/10"
[ExposureBiasValue] =>
string(4) =>
"0/10"
[MaxApertureValue] =>
string(5) =>
"37/10"
[MeteringMode] =>
integer(5)
[Flash] =>
integer(1)
[FocalLength] =>
string(6) =>
"180/10"
[MakerNote] =>
string(214) =>
"FUJIFILM\f\000\000\000\017\000\000\000\a\000\004\000\000\0000130\000\020\002\ ...
[FlashPixVersion] =>
string(4) =>
"0100"
[ColorSpace] =>
integer(1)
[ExifImageWidth] =>
integer(1280)
[ExifImageLength] =>
integer(960)
[InteroperabilityOffset] =>
integer(952)
[FocalPlaneXResolution] =>
string(6) =>
"2453/1"
[FocalPlaneYResolution] =>
string(6) =>
"2453/1"
[FocalPlaneResolutionUnit] =>
integer(3)
[SensingMethod] =>
integer(2)
[FileSource] =>
string(1) =>
"\003"
[SceneType] =>
string(1) =>
"\001"
[InterOperabilityIndex] =>
string(3) =>
"R98"
[InterOperabilityVersion] =>
string(4) =>
"0100"
[Version] =>
string(4) =>
"0130"
[Quality] =>
string(7) =>
"NORMAL "
[Sharpness] =>
integer(3)
[WhiteBalance] =>
integer(0)
[FlashMode] =>
integer(3)
[FlashStrength] =>
string(4) =>
"0/10"
[Macro] =>
integer(0)
[FocusMode] =>
integer(0)
[SlowSync] =>
integer(0)
[PictureMode] =>
integer(0)
[ContTake] =>
integer(0)
[UndefinedTag:0x1200] =>
integer(0)
[BlurWarning] =>
integer(0)
[FocusWarning] =>
integer(1)
[AEWarning ] =>
integer(1)
I originally wrote html_vardump() in order to debug class.rFastTemplate.php so I could see exactly what was inside that big class variable I was creating. So, yes, it will handle class variables, too. The file containing html_vardump() has a couple of other functions I’ve been working on (off and on). Feel free to discard them if you don’t like them.
Search
.Archives
- October 2024 (1)
- May 2024 (2)
- April 2024 (3)
- September 2022 (5)
- April 2022 (1)
- January 2022 (3)
- December 2021 (4)
- September 2021 (3)
- July 2021 (1)
- January 2021 (1)
- November 2020 (2)
- October 2020 (2)
- September 2020 (2)
- August 2020 (5)
- July 2020 (1)
- November 2019 (2)
- September 2019 (1)
- August 2019 (2)
- September 2017 (1)
- August 2017 (1)
- September 2015 (3)
- August 2015 (2)
- June 2015 (5)
- May 2015 (3)
- May 2013 (2)
- January 2013 (1)
- December 2012 (2)
- September 2012 (1)
- June 2012 (1)
- May 2012 (1)
- October 2011 (2)
- September 2011 (2)
- April 2011 (2)
- March 2011 (10)
- January 2011 (8)
- November 2010 (2)
- October 2010 (1)
- September 2010 (3)
- August 2010 (2)
- July 2010 (1)
- June 2010 (1)
- April 2010 (3)
- February 2010 (3)
- January 2010 (3)
- December 2009 (6)
- November 2009 (3)
- October 2009 (7)
- September 2009 (8)
- August 2009 (4)
- July 2009 (1)
- June 2009 (2)
- May 2009 (2)
- April 2009 (7)
- March 2009 (1)
- February 2009 (6)
- January 2009 (4)
- December 2008 (4)
- November 2008 (3)
- October 2008 (11)
- September 2008 (4)
- August 2008 (5)
- July 2008 (5)
- June 2008 (2)
- April 2008 (4)
- March 2008 (18)
- February 2008 (9)
- November 2007 (1)
- October 2007 (3)
- July 2007 (3)
- April 2007 (1)
- March 2007 (6)
- February 2007 (3)
- December 2006 (3)
- October 2006 (4)
- September 2006 (1)
- July 2006 (5)
- May 2006 (10)
- April 2006 (9)