Author |
Message |
wHiTeHaT
Life Cycles Becoming CPU Cycles
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 18, 2004
Posts: 579
|
Posted:
Thu Mar 25, 2010 12:00 pm |
|
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) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Thu Mar 25, 2010 1:53 pm |
|
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. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
fkelly
Former Moderator in Good Standing
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Thu Mar 25, 2010 2:39 pm |
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
wHiTeHaT
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Mar 25, 2010 3:05 pm |
|
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? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
fkelly
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Mar 25, 2010 3:23 pm |
|
"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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sat Mar 27, 2010 11:32 am |
|
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! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|