[PHP] Print a variable's name
I'd like to print a variable's name in a procedure along with it's value Is there a way to do this? for example: --- function showvar($somevar) { echo Now showing: . ... code to show var name . .\n; echo Value: .$somevar; } $s1 = Hello World; showvar($s1); --- would produce: --- Now showing: $s1 Value: Hello World --- many thanks in advance... Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Print a variable's name
Thanks Ryan, but what I want is to be able to pass any variable to a procedure and have the variable name and value printed by the procedure. Can this be done? I'm trying to extend my library of debugging functions/procedures by having a procedure which can be used to inspect a variable whenever I call it. Thanks Ahbaid Ryan A wrote: Just escape it... eg: $ryan = something; echo \$ryan =.$ryan; that would print: $ryan = something HTH. Cheers, -Ryan On 5/5/2004 5:02:25 PM, [EMAIL PROTECTED] wrote: I'd like to print a variable's name in a procedure along with it's value Is there a way to do this? for example: -- - function showvar($somevar) { echo Now showing: . ... code to show var name . .\n; echo Value: .$somevar; } $s1 = Hello World; showvar($s1); -- - would produce: -- - Now showing: $s1 Value: Hello World -- - many thanks in advance... Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Print a variable's name - FIXED
I didn't say SOLVED becuase this gets me sor of what I want : I added to the function an optional parameter so that if I reall wanted the var name to show I can pass it in... I know it's messy, but for debugging it's fine: function showvar($var,$varname=Var: ) { echo Now Showing .$varname.: br\n; echo $var; } This way I supply the var name if I want to.. such as: $s1 = Hello World; showvar($s1,s1); or showvar($s1); thanks all Ahbaid. Dave Avent wrote: $test = Hello World!; function showvar($var) { foreach($GLOBALS as $key = $value) { if($value == $var) { $varname = $key; } } echo Variable Name: .$varname.br\n; echo Variable Value: .$var.br\n; } showvar($test); This is the only thing that works for me.I know it is messy -Original Message- From: Michael Sims [mailto:[EMAIL PROTECTED] Sent: 05 May 2004 4:23 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Print a variable's name Ahbaid Gaffoor wrote: Thanks Ryan, but what I want is to be able to pass any variable to a procedure and have the variable name and value printed by the procedure. Can this be done? I'm trying to extend my library of debugging functions/procedures by having a procedure which can be used to inspect a variable whenever I call it. This is a bit kludgy, but should work: function showvar($varname) { if (!isset($GLOBALS[$varname])) { return; } echo Now showing: $varname\n; echo Value: .$GLOBALS[$varname].\n; } $s1 = Hello World; showvar('s1'); HTH
Re: [PHP] Print a variable's name
That's the way I ended up going pass the name and value along :) Not what I was hoping for, but it gets the job done, and it's only for debugging pruposes thanks Ahbaid. Michal Migurski wrote: but what I want is to be able to pass any variable to a procedure and have the variable name and value printed by the procedure. Because PHP passes arguments by value, you will be out of luck in most cases -- by the time your debugging function sees the argument, it's no longer tied to the calling scope. Michael Sims' example function works only for variables in the global scope, which probably won't work for anything complex enough to need its own debugging library. I'm trying to extend my library of debugging functions/procedures by having a procedure which can be used to inspect a variable whenever I call it. You may find what you need in debug_backtrace(). Alternatively, just pass the variable name along: function echo_var($varname, $varvalue) { printf(%s: %s\n, $varname, $varvalue); } ...Which isn't much of an improvement over a plain old echo/print. And if that's good enough for Brian Kernighan, I'd hope it's good enough for you. :D - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html
[PHP] Control Structure Syntax Question
Someone had posted a tip for using an abbreviated form of an if.. else structure... It looked something like: $x : action1 : action2; I'm trying to shorten having to do the following: if ($x) { action1; } else { action 2; } can someone please post the syntax if they know it? I am reading the fine documentation but can't find it... many thanks Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Control Structure Syntax Question
Yeah, but if my code is less readable, my job security goes up ;) (Kidding) Thanks for all your help folks, that's what I needed. regards Ahbaid Richard Davey wrote: Hello Ahbaid, Tuesday, March 9, 2004, 11:42:21 PM, you wrote: AG Someone had posted a tip for using an abbreviated form of an if.. else AG structure... AG It looked something like: AG $x : action1 : action2; $x ? xxx : xxx But it makes your code less readable IMHO and offers no tangible benefit whatsoever. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Solved [PHP] Weird Problem with INPUT tag
Yep, that was indeed the problem. Many thanks for your help. I just could not see that at all regards Ahbaid Richard Davey wrote: Hello Ahbaid, Sunday, February 29, 2004, 6:33:45 AM, you wrote: AG this uses a FORM with INPUT tags, what is weird is that under IE6 some AG of the INPUT fields are showing up with yellow AG backgrounds Sounds to me like you have the Google toolbar installed with the AutoFill option enabled. See the preferences to turn the yellow background off. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Weird Problem with INPUT tag
I'm building a site using PHP for the navigation section of each page and to to do the general page layout. To this effect I have created php functions to structure the pages and I fill in the static text specific to each page. This all works. I have now got to the point where I am doing a page to send emails... this uses a FORM with INPUT tags, what is weird is that under IE6 some of the INPUT fields are showing up with yellow backgrounds They all use the same style sheet class, and simply varying the spelling of the field name and label from emil to ail fixes it!!! for example the code below is coorrect (no yellowing): tr height=1 td class=labelEmil/td tdnbsp/td td colspan=2 input type=text name=emil size=80 class=finput /td /tr but the following code is yellowed: tr height=1 td class=labelEmail/td tdnbsp/td td colspan=2 input type=text name=email size=80 class=finput /td /tr Now this goes away under Mozilla or Firebird browsers, so I know that this is specific to IE6 I'd really like to know why this is happening and how to correct this behaviour, and I cannot tell my client to not use IE. thanks for all your help the link below shows the problem in action, note the Email and Emil sections http://geosysllc.ilmtech.com/contact many thanks, Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP IDE?
My folding is setup to work based on a function to fold and unfold. I have the function mapped to my spacebar, so pressing it while in escape mode will either fold or unfold the code Place this in your .vimrc and then you can use {{{ and }}} as your start and end tags if has(folding) highlight Folded term=standout ctermfg=Yellow ctermbg=Blue set commentstring=#%s set fillchars=vert:|,fold: set foldmethod=marker set foldmarker={{{,}}} fun! ToggleFold() if foldlevel('.') == 0 normal! l else if foldclosed('.') 0 . foldclose else . foldopen endif endif Clear status line echo endfun Map this function to Space key. noremap space :call ToggleFold()CR endif The reasons given about vim (or vi) being on platforms are exactly the same that I have stuck with vim (vi) over the years. In some shops they do not allow emacs on their boxes, some don't install additional editors, but vi has always been a constant. this is just my experience, so please note that I am not berating anyone for their choice of editor... regards Ahbaid. Wouter van Vliet wrote: Yeah .. vim is my god too. You can do so many things with so little keystrokes. And it basically has the best syntax highlighting I've ever seen. With some easy tricks you can even let it highlight your own functions. I haven't doen so, but I know it's possible :P... Also, it exists on most servers so you can work directly on the server. Without having to mess with (Samba) filesharing. Another advantage is that it runs both on Linux as well as on Windows. W. (ps. Ahbaid or anyone else .. how can I get code to re-fold. I've setup my vim to fold every PHP function and class, which works when I load te file. But when I'm done editing a certain block, what do I do to make it fold back in again?) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP IDE?
with folding you can fold your code in chunks, you basically setup a start fold and an end fold and place code between them, then you can open and close (fold) that block of code as you need to or don't need to see it... for example: # {{{ PHP Code to do something... .. .. 1 lines of code... .. .. # }}} would collapse to one line when folded and look something like: + PHP Code to do something then when you hit space on it it expands. (I use {{{ and }}} as my start and end folds) ctags allows you to build a dictionary of words which you can hook into vim, that way you can do tab completion on PHP words etc. I also like to map keystrokes to coding templates for things like functions, loops, declarations etc. Everyone's got their own setup :) Plus I always use a CVS repository for my work, so my routine of, code, test, commit is habit. Looking at the responses there seems to be a lot of neat editors out there, to each his own. regards, Ahbaid. Jough Jeaux wrote: Hmm, I'm currently a vim user also. You'll have to elaborate on this folding and ctag business though... --- Ahbaid Gaffoor [EMAIL PROTECTED] wrote: vim - with folding and ctags sweet. Ahbaid Jough Jeaux wrote: Was wondering what everyone's favortie IDE is for coding in PHP. I've got a big PHP project in the works. I'll be doing alot with it and am looking for ways to boost my productivity. --Jough __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/
Re: [PHP] PHP IDE?
vim - with folding and ctags sweet. Ahbaid Jough Jeaux wrote: Was wondering what everyone's favortie IDE is for coding in PHP. I've got a big PHP project in the works. I'll be doing alot with it and am looking for ways to boost my productivity. --Jough __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP - Oracle - BLOBs - Display BLOB data in a table
I have written the first half of my application which stores images in BLOB fields of an oracle database. This part of my app. works fine. I am now trying to download the database stored blob and display it in my web page. I am able to get the blob data into a variable called $blobdata. If I just throw up a fresh page and issue the following code, the image displays fine: ?php Header( Content-type: $type); echo $blobdata; ? Assume that I have a function which when given an image id it returns the blob data as follows: $blobdata = get_image_data(2); // Get the blob data for image as stored in the database with id = 2 However, I would like to be able to place the blobdata say in a table cell as follows: tabletrtd ?php $blobdata = get_image_data(2); echo $blobdata; ? /td/tr only problem is that I am getting gobbledygook charcaters in the cell as the raw data is being printed, what sort of HTML or PHP functions should I use to do this? many thanks, Ahbaid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] BLOB - PHP Peformance DB vs. Web server Opinions
Thanks to all who helped with my earlier questions on pulling BLOB data out of Oracle using PHP. I am however finding that performance is slow when downloading huge files from the database. A typical 2Meg GIF file being downloaded from Oracle via. PHP is taking about thirty seconds. Everything (database, web server, development box) are all on a 100 Megabit Switched ethernet setup. 1) Are there any pitfalls or guidelines when working with BLOBs and web apps? 2) Is there any advice for or against storing images as blobs in a database? Or is it better to store them on the web server file system? So far I am finding the web server file system to be faster, but I tend to think that it is less manageable from a relational data perspective. thoughts? thanks Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date question
Beautiful, many thanks Ahbaid. Martin Cameron wrote: $ndays=14; function get_next_dates($ndays) { $today=date(m-d-Y,mktime(0,0,0,date(m),date(d),date(Y))); $forward_date=date(m-d-Y,mktime(0,0,0,date(m),date(d)+$few_days,date(Y))); print h1$today === $few_days === $forward_date/h1; for($i=0;$i$ndays;$i++) { $new_days_array[]=date(m-d-Y,mktime(0,0,0,date(m),date(d)+$i,date(Y))); } return($new_days_array); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date question
Hello all, I would like to create a php function as follows: function get_next_dates($ndays) { /* 1. get the current date 2. create an array say $results 3. Store the dates for the next $ndays in $results */ return $results } So in my main program I can include the file with the function and use it as follows: ?php $next_4_dates = get_next_dates(4); ? $next_4_days[0] - 11/20 $next_4_days[1] - 11/21 $next_4_days[2] - 11/22 $next_4_days[3] - 11/23 if today was 11/19 Is there an easy way to do this? Can I somehow use something like getdate+7 say to get 7 days ahead? many thanks, Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Oracle 9iAS - Add PHP module
I'm running Oracle 9iAS on Linux, does anyone know if it's possible to add PHP to it as a module? Given that it's based on Apache? are there any docs out there on how to do this? thanks Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Documentation procedure
Is there any utility that can be run against a php script to generate documentation of the functions in that script? Sort of like javadoc is for java code thanks Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Documentation procedure
Thank you! Just what I needed. Ahbaid Boyan Nedkov wrote: http://phpdocu.sourceforge.net/ http://www.callowayprints.com/phpdoc/ http://sourceforge.net/projects/phpdocu/ http://www.stack.nl/~dimitri/doxygen/ Ahbaid Gaffoor wrote: Is there any utility that can be run against a php script to generate documentation of the functions in that script? Sort of like javadoc is for java code thanks Ahbaid -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Register Procedure - AOLServer / TCL - PHP Equivalent
Hello all, when using AOL Server you can register a procedure against the server and use this as your web page. for example a procedure that prints Hello World as an HTML page name helloproc So if I call up http://server/helloproc the procedure serves up the page to the client browser Is such a feature provided under Apache / PHP? If so, how is it implemented? A short example would be helpful. thanks, Ahbaid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php