Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts

    if condition clause

    i found this thru my error checking on a script.

    PHP Code:
    if(condition)
      { 
    It is inside a php section of code. It was also in an older script, the original but i guess it never got triggered cause it never got flagged.

    It is flagged now because it is not $condition .

    I did a search of the script with ransack and could not find anything that was labeled as a function or $value by the same name.

    So is this a proper call?


    here is that section of file..

    PHP Code:

     
    if($rec['status']=="Pending"
         {
           if(
    condition)
            {

            
    $variable = <<<XYZ
            <html>
            <body>
           <style type='text/css'>
            div.box
            {
                border: solid 1px #CCCCCC;
                background-color: #f7ef14;
                padding: 4px;
                margin: 15px 4px 0px 4px;
                display: table;
            }
            </style>
           <div style='width: 100%; border: solid 2px black;'>
            <h3><center>This Is Pending Approval</center></h3>
            <center><div class='box'>
                Pending Approval!
                       </div><br />
            <center><span color='red'>Your IP And Domain Have Been Recorded</span></center>
           </div>
            XYZ;

           echo $variable;
           echo "Contact: <a href='mailto:$adm_mail'>$sitename</a>";
           echo "    or Visit: <a href='$soft_address'>$soft_address_name</a>";

            }//close if condition 

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,090
    Thanks
    51
    Thanked 506 Times in 493 Posts
    It must be a defined constant somewhere. That or its a PHP magic variable like __LINE__ and __FILE__. I've never seen it myself though but that doesn't mean it doesn't exist.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    durangod (02-08-2013)

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    All magic in PHP starts with __. Lets see if I can find a link for that. Ah, here it is: http://www.php.net/manual/en/userlandnaming.rules.php

    condition is not a valid pre-defined constant. Either it was set as constant prior within script, or you simply did not have your error reporting set highly enough. If condition is not declared, it will trigger E_NOTICE and return true, since the string 'condition' is true.

    So if its not a valid defined constant, than you've been returning true regardless of if it should have been or not.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • The Following 2 Users Say Thank You to Fou-Lu For This Useful Post:

    durangod (02-08-2013), tangoforce (02-08-2013)

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Thank you both, yep i guess thats what it was never flagged because it was true. This page was actually done by someone else that i let help me on this project awhile back and sadly i was unable to get ahold of him.

    I will probably just remove it. As i have done a search for condition, $condition, condition ( <-- in case it is a function, and function condition, *condition* , and nothing has been found.

    So i will just remove it.

    Thanks to you both..

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,090
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by Fou-Lu View Post
    All magic in PHP starts with __. Lets see if I can find a link for that. Ah, here it is: http://www.php.net/manual/en/userlandnaming.rules.php
    I had a feeling that was the case but (despite my constant nagging of others) I don't spend enough time on the php manual to know it inside out like you do

    Never thought about mentioning error reporting.. I assumed DG would have that turned on anyway after hanging around here and seeing it mentioned plenty of times.. my bad lol
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #6
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Yes Sir i did have errors on, thats how i found it ... i must be learning lol... And fyi i did remove it and it seems to be working fine. I know that at one time we had talked about placing a new condition for approval and that must have been when that was placed in there and it was just left by mistake from development. Back then i was not so savy to catch things and trusted more than i should and did not oversee things so much.

    But now that i am doing everything myself i am very very picky and i try not to leave much to chance.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Yeppers, what I mean though is that your old configuration would also have the same errors, but the reporting wasn't set to include E_NOTICE.

    I'm not sure what's sadder actually, the amount of what I know when I look through the manual, or what it is I *don't* have memorized O.o. There's just so much to this language.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    There has to be a point (a plateau) where you know so much about the language that even if you dont read the manual i would think the answer has to be logical or should be. When you get to the point that you have to plug your ears so it dont leak out its time to slow down a bit i would think...

  • #9
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,090
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by Fou-Lu View Post
    There's just so much to this language.
    I think other languages are worse - eg for windows programs. You not only have the language to worry about but memory allocation, pointers, buffers, threads, critical sections, thread synchronization, so many different types of DB its confusing where to start etc etc.

    PHP is a doddle IMO. Sure, takes a while to get the grip of the basics and the difference between a web language and a windows language but by comparison there is a lot less to worry about I'd say. The beauty with php is that if you want to do something and don't know how, it's usually a case of hitting google, grabbing someone elses code, modifying it to your needs and then debugging until its perfect. In windows languages it doesn't always work out like that.. you can be missing a dependant component for a start, have the wrong IDE for a component set... ah it's a nightmare.

    Object Pascal (Lazarus / Delphi).. now there is a swine to tame. The amount of hassle I've had with that language and components for this and that.. the IDE alone is a monster. I really should try and switch to something else but I have a few too many projects that need to be finished first
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #10
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Never dealt with Pascal but i have been introduced way back when in college to Assembly and that was more than enough for me to say no thanks to that.

    And i totally agree with you on the windows deal. Even at the VPS hosting level apache/linux side is soooo much easier. Sure both sides have tons of options but OMG i just had to set up a VPS on Windows and it was a royal pain. But i guess everything is easy once you know how and work with it. Im sure even the elite Pascal coders might think what they do is easy, its all relative i suppose.

  • #11
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,090
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Well thats just it, compared to some other languages I would say that Pascal is probably easier than others where you have to start from the ground up (which as far as I understand is what you do with c, c++). Fou knows about all those 'other' languages so he will be better to comment. With Object Pascal you get an IDE, form designer, events handlers etc.. in theory its a doddle.. at least until you end up dealing with the OS and different threads etc and then it can get out of hand very quickly and you really have to be thoughtful about how you design the program. When you've used a language like that, PHP becomes a lot easier to use as you don't have a lot of that to worry about, it's just a flow of logic and nothing else really.

    Assembly.. thats somewhat of a murky beast. Even in windows 3rd level languages you're often expected to understand hex (which the windows calc can translate) and assembly instructions. The problem with assembly is that in a windows program it can literally be several thousand lines of code just to do the basics. I've tried debugging code in the delphi ide by following the assembly instructions and you end up jumping around all over the place for thousands of lines before you see anything you would remotely recognise as familiar code.

    IMO assembly is better suited to hardware devices such as PIC processors made by microchip and other things like the Atmel range (used for arduino boards) but even arduino uses a c++ compiler (I think its ++) so that you can write 3rd level code and compile it down before uploading to the board. I have another device (an electronics learning board thing) which has a basic chip with just 15 instructions.. it accepts input states as hex numbers and output states as hex numbers.. but actually trying to compare the state of each pin is a real head scratcher. I wrote a basic burglar alarm on it once, it could save the initial state of all the pins but then trying to loop through and compare each pin to its original state using hex numbers... urrrrrgggh NO! With assembly the hardest thing to understand is registers and all that cr*p. There really is no need for the complex wording they use to describe it all either.

    There are other languages that are even worse too.. I remember one years ago that used symbols on graphical lines. It was really weird and somewhat of a brain twister. I'd never touch that again..
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I think you may be mistaken on what I am referring to as the complexity.
    PHP has a very large core api, and it is rife with inconsistencies. From the simple such as reversed evaluation on ternary operations, to the complex with inconsistent function names and parameter lists. Tack on an (actually pretty good considering all) OO interface to the procedural language, and that has just doubled the complexity of it all.
    So with every step in the PHP language, from the primitive to the complex, PHP is one of the most offending languages when it comes to, well, logic. It was designed to be used by those with less programming experience, so the idea is to try and make it easier for starting simple websites. Problem is as developers become better and programming in general, PHP starts becoming quite cumbersome in how it has implemented its functions.
    This is why I never recommend PHP as a starting language as it is so very. . . unique.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #13
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Got ya Fou-Lu

    I think i was attracted to php because of my love for COBOL in my college days.

  • #14
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,090
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by Fou-Lu View Post
    PHP has a very large core api, and it is rife with inconsistencies. From the simple such as reversed evaluation on ternary operations, to the complex with inconsistent function names and parameter lists. Tack on an (actually pretty good considering all) OO interface to the procedural language, and that has just doubled the complexity of it all.
    So with every step in the PHP language, from the primitive to the complex, PHP is one of the most offending languages when it comes to, well, logic.
    No I see what you mean there with those points and coming from Object Pascal, I agree entirely. It's all a bit weird but I've just got used to going along with it to be honest.

    From my POV though, actually using PHP is still a lot less complex than a win32 language where you have so much else to worry about. Have you ever seen the souce code for Indy Sockets? - Ever tried debugging it while you have multiple threads running? It's not nice but you have to have multiple threads to make sure the server will handle everything properly. With PHP you don't get any hassle like that really. While I agree it has a lot of other weird things going on, it's also a charm to use for its simplicity in other things. I'll admit the annoying function names and the parameter lists are a mega pain but then I cheated to solve that - I have a javascript button on my browser tool bar with a prompt - type in the functionname, hit ok and it'll look up the function on php.net OR take me to a search results page which will list anything similar. That lets me get to the parameter list in seconds so from my POV, this is not such a big issue.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •