Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Really Quick Question (i Hope)
ginginca
post Nov 19 2006, 09:41 PM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 250
Joined: 6-July 06
From: The net (or at least that's what my family says)
Member No.: 14,330



I'm writing some error checking code and my PHP editor colors the script ... and am running into a (dumb) question.

(Sorry - I'm learning).

I have typed the following:

CODE
if (!is_integer($item_1_qty))

       {
        //qty is not a number
        $redirect_to = 'order_form.php?error=1';    
        header("Location: $redirect_to");
        exit();    
    }




I don't understand why my is_integer is black when I am expecting it to be blue.

When you do if (empty$ etc ... empty is blue. I'm a bit confused about that.

Gin

This post has been edited by ginginca: Nov 19 2006, 10:05 PM
Go to the top of the page
 
+Quote Post
vujsa
post Nov 20 2006, 12:29 AM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 884
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



I guess that this could just be you editor acting up. I'm not sure what your editor is set up to do with the various elements in your script. Here is what PHP Designer 2005 does with the code.

QUOTE

if (!is_integer($item_1_qty))

          {
          //qty is not a number
          $redirect_to = 'order_form.php?error=1';
          header("Location: $redirect_to");
          exit();
     }



But here is what I get for empty:
QUOTE

if (!empty($item_1_qty))

          {
          //qty is not a number
          $redirect_to = 'order_form.php?error=1';
          header("Location: $redirect_to");
          exit();
     }



Perhapes different types of functions are highlighted differently or maybe the editor doesn't know newer function or can't properly determine what a function looks like. header() is a function but is blue in both examples but exit() is green in both. They are both common functions so why is one green and the other blue? I suppose that there could be PHP version considerations taken into account and green is always compatable but you ned to check the PHP version for the blue.

Personally, I have PHP Designer 2005 but I never use it. I still use an old version of CuteHTML which tries to highlight all my code like it was HTML. tongue.gif As a result, I never even notice the color of the text anymore. Old dog new tricks etc...

I guess that my point is that while these syntax highlighters are helpful at times, they shouldn't be relied upon for critical applications.

So the answer to your "dumb question" is that I really don't know so that makes us both "dumb" I guess!

vujsa
Go to the top of the page
 
+Quote Post
jlhaslip
post Nov 20 2006, 02:46 AM
Post #3


Advanced Member
Group Icon

Group: Members
Posts: 182
Joined: 15-November 05
From: Inland from the Left Coast of Canada
Member No.: 9,627



is_integer() is an alias for is_int(). Maybe try is_int() or is_numeric after casting the variable as an integer in the comparison?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Hotkeys / Keyboard Quick Launch Keys In Linux(5)
  2. Question About Professional 3d Animating(20)
  3. Force Object To Load Last(2)
  4. Question: Vector Based Animation?(4)
  5. Mp3 Questions(14)
  6. Question About Asp Now() Function(6)
  7. Switch Network Settings With Batch Files(18)
  8. How To Install Applications In Fedora(12)
  9. Web Browser And Taskbar Problems (web Browser Disappears)(7)
  10. VB.NET / MS Access Question(6)
  11. What's The Best CMS(35)
  12. Ipod Hardware And Software Question(8)
  13. How To Get Quick And Easy Levels In Runescape(12)
  14. Gaia Online Question(6)
  15. Do Google Search Better Than Yahoo?(14)
  1. Mysql Query Question(3)
  2. Question(2)
  3. File Storage Question?(4)
  4. A Quick Start Guide Anyone?(6)
  5. Mysql Question(inserting Number From A Textfield)(3)
  6. 4 Ram Slots Question(6)
  7. Private Servers Question(13)
  8. Dynamic Php Image And Better Php Code Question(10)
  9. Joomla License Question(1)
  10. Simple Java Question(1)
  11. Php Question, Help Please(5)
  12. Question About Opengl Codes.(0)
  13. Css Minus The <p>(9)


 



- Lo-Fi Version Time is now: 22nd August 2008 - 02:50 AM