Raised This Month: $ Target: $400
 0% 

difference between new and static?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-25-2012 , 05:21   Re: difference between new and static?
Reply With Quote #2

A static variable couldn't be initialized immediately, then it will take less performance.
Also, it remains unchanged in function and won't be initialized again. Only a new attribution will change the static's variable value.

PHP Code:
new 1337// YEYEYE
static 1337// NONONO
static i1337// YEYEYE 
PHP Code:
public MyFunction( )
{
  static 
msgSayText;
  if( !
msgSayText )
    
msgSayText get_user_msgid"SayText" );

  
server_print"SayText's index is %d"msgSayText );

  
// Native get_user_msgid will be executed once in this function named MyFunction because msgSayText's value won't be lost.

__________________

Last edited by claudiuhks; 04-25-2012 at 05:29.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode