| Author |
Message |
wHiTeHaT Involved


Joined: Jul 18, 2004 Posts: 442 Location: Netherlands
|
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) |
|
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
Posted:
Thu Mar 25, 2010 1:53 pm |
|
|
|
 |
fkelly Moderator

Joined: Aug 30, 2005 Posts: 3186 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. |
|
|
|
 |
wHiTeHaT Involved


Joined: Jul 18, 2004 Posts: 442 Location: Netherlands
|
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? |
|
|
|
 |
fkelly Moderator

Joined: Aug 30, 2005 Posts: 3186 Location: near Albany NY
|
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. |
|
|
|
 |
montego Site Admin

Joined: Aug 29, 2004 Posts: 9136 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. |
|
|
|
 |
|
|
|
|