Php set variable to null




















You could also set the variable to null, however this is how the two approaches differ:. As of php 7. You should not use it in this fashion you should look into using unset instead. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.

Learn more. Ask Question. Asked 12 years, 1 month ago. Active 1 year, 10 months ago. Viewed 60k times. Improve this question. Your assumption would be correct for both php and.

Improve this answer. Captain Giraffe Captain Giraffe There are two things to consider here: memory management and defensive coding. Chris Eberle Chris Eberle Yeah, that's why this example doesn't work. Doing it at the end like that is just plain old superstition.

Narf Narf Any variable will be unset automatically once it gets out of current scope. He's talking about when the object were not to go out of scope for a while. As CG says, you are correct in assuming this is unnecessary.

Robert Martin Robert Martin Trust PHP to manage this stuff for you. Lightness Races in Orbit Lightness Races in Orbit k 70 70 gold badges silver badges bronze badges. If you need too free variable's memory, you'd better use unset. Kibbee Kibbee Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.

Submit a Pull Request Report a Bug. NULL The special null value represents a variable with no value. A variable is considered to be null if: it has been assigned the constant null. Syntax There is only one value of type null , and that is the case-insensitive constant null.

On the other hand, Incrementation works simply as expected. Hope this helps :.



0コメント

  • 1000 / 1000