Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
wHiTeHaT
Life Cycles Becoming CPU Cycles



Joined: Jul 18, 2004
Posts: 579

PostPosted: Thu Mar 25, 2010 12:00 pm Reply with quote

what is a better way to write code for ravennuke:

example
Code:
$code = "modules/Submit_News/uploads/$random_number/";

or
Code:
$code = 'modules/Submit_News/uploads/'.$random_number.'/';


i assume second example , but i would like to hear it from more experienced coder(s)
 
View user's profile Send private message Send e-mail
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Mar 25, 2010 1:53 pm Reply with quote

The second one.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Thu Mar 25, 2010 2:39 pm Reply with quote

Put yourself in place of the PHP parser. In the first example it has to parse every character looking for, say, variables and then substituting values in where it finds one. In the second case it can simply proceed from the first single quote to the second interpreting the characters literally and not testing any of them to see if they refer to a variable. That's a lot of tests skipped in a big program and it's one reason why the single quote, string concatenation method is used throughout Ravennuke and why the RN team spent a lot of time a couple of years ago going through the code to do that.
 
View user's profile Send private message Visit poster's website
wHiTeHaT







PostPosted: Thu Mar 25, 2010 3:05 pm Reply with quote

i understand , thank you for your explenation.... so
Code:
   if($notify) {

      $notify_message = "$notify_message\n\n\n========================================================\n$subject\n\n\n$story\n\n$storyext\n\n$name";
      /*
       * TegoNuke Mailer added by montego for 2.20.00
       */
      $mailsuccess = false;
      if (defined('TNML_IS_ACTIVE') and validate_mail($notify_from) !== false) {
         $mailsuccess = tnml_fMailer($notify_email, $notify_subject, $notify_message, $notify_from, $sitename);
      } else {
         $mailsuccess = mail($notify_email, $notify_subject, $notify_message, "From: $sitename <$notify_from>\nX-Mailer: PHP/" . phpversion());
      }
      /*
       * end of TegoNuke Mailer add
       */
   }
needs revisiting?
 
fkelly







PostPosted: Thu Mar 25, 2010 3:23 pm Reply with quote

"Needs" is subject to interpretation. While "efficiency" is important so is the workload of the RN team. We did not necessarily convert EVERY line in Ravennuke to the single quotes, string concatenation method. And certain things are more difficult to convert than others and you really have to thoroughly test everything you convert. Especially where we used Open Source code from other sources besides the core *Nuke we did not always have the time to go through it thoroughly to do these conversions.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Mar 27, 2010 11:32 am Reply with quote

fkelly is exactly right. I wouldn't change these lines personally (because I coded them this one in the first place). What is the point? The "\n" (line feed) character MUST be inside double quotes or use some other way to generate that special character in the output.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©