Jump to content

PHP Strict

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
What are some things I need to pay attention to to be sure my programs are ok for php strict mode? I am only working on a shared server and I don't really have a way to test it in strict myself.

In the past I think someone said to have all error reporting on and then fix whatever shows up. Is it as simple as that? In most cases they said that the error would be that something isn't defined and that I need to use isset() in my if statements to avoid those errors.

#2
Khaotic

Khaotic

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
As you were told, make sure you have your error debugging on. Yes, most errors are as simple as forgetting to specify something or what not. Just make sure you have your error reporting on, and you should be good to go.

#3
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
$start = $this->request['st'] ? intval($this->request['st']) : 0;

That is an exact example from the forum software itself which I simply copied when needed in my modification. But it causes a notice that "st is undefined". I thought that first part is equivalent to isset() which wouldn't cause any sort of error or notice or whatever. Are they misformatting that? Do I need to put isset() around the first part?

I think I fixed all other issues, but the forum software ITSELF has tons of notices. Does strict mess up if there is any error, notice, etc... at all? If so then their own software won't be working in strict mode either.

Edited by Jaan, 02 May 2009 - 01:58 AM.
Please use code tags when you're posting your codes!


#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts

Quote

I thought that first part is equivalent to isset()
That is not the case. Each expression needs to evaluate to a boolean value and unless $this->request['st'] is true or false you will get the error you are seeing. You can either use isset() or empty() to fix this issue.

#5
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
Thanks. I should have just tried it with isset before asking. Blah.

What happens in strict mode if there are notices? Does it then not work or does it simply show the notices or what?

Now I see no other issues, but I know there will be some hidden cases that could crop up. But with the Invision software itself having tons and TONS of notices, I don't know why I even bothered getting rid of my own. Guess better to do thigns right even if the software it's revolving around has some loose ends though.