Click here to Skip to main content
15,904,655 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: PHP Pin
Marc Clifton6-Oct-14 10:33
mvaMarc Clifton6-Oct-14 10:33 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 10:38
professionalJeremy Falcon6-Oct-14 10:38 
GeneralRe: PHP PinPopular
David O'Neil6-Oct-14 11:40
professionalDavid O'Neil6-Oct-14 11:40 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 11:47
professionalJeremy Falcon6-Oct-14 11:47 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 12:13
professionalDavid O'Neil6-Oct-14 12:13 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 12:29
professionalJeremy Falcon6-Oct-14 12:29 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 12:36
professionalDavid O'Neil6-Oct-14 12:36 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 13:20
professionalJeremy Falcon6-Oct-14 13:20 
It looks pretty solid. I do have a few nit-picky things, just to help tighten it up. Not required, but will help it run a bit smoother...
Article Code:
require_once("phpPayPalIpnClass.php");
Relative paths are a no-go if you ever want to run this code on the command line instead of the web. That's because your current directory will be the directory you are in when calling the script and not the one the script is actually in. The web server dances around that. What I do is something like this in the main PHP file to the app to handle both web and command line invocations.
PHP
define('BASE_PATH', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
require_once BASE_PATH . 'my/relative/path.php';


Article Code:
$this->logger->log("Processing a payment.\r\n");
Instead of explicit line breaks like that, it's better to use the constant PHP_EOL, so platform translation happens automatically.
PHP
$this->logger->log("Processing a payment." . PHP_EOL);


Article Code:
$_POST['txn_id']
A hacker can easily mess with GET or POST data. And, if you try to access a variable that way without checking for its existence first the script can crash and burn. So I always validate / sanitize my input and perform checks before using them. Something like this at the very least...
PHP
if(isset($_POST['txn_id'])) /* now we can use it */


Article Code:
$this->logger->log("\r\nSENT:\r\n" . $header . $response . "\r\n\r\n");
If you're using double quotes for a string literal you don't have concatenate strings to include variables. You can just type them as part of the string and PHP will translate it automatically.
PHP
$nl = PHP_EOL;
$this->logger->log("$nlSENT:$nl$header$response$nl$nl");


Anyway, that's at first glance. Should make it a bit more cool looking if nothing else.
Jeremy Falcon

GeneralRe: PHP Pin
David O'Neil6-Oct-14 13:25
professionalDavid O'Neil6-Oct-14 13:25 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 13:38
professionalDavid O'Neil6-Oct-14 13:38 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 13:52
professionalJeremy Falcon6-Oct-14 13:52 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 14:02
professionalDavid O'Neil6-Oct-14 14:02 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 14:08
professionalJeremy Falcon6-Oct-14 14:08 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 14:25
professionalDavid O'Neil6-Oct-14 14:25 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 14:36
professionalJeremy Falcon6-Oct-14 14:36 
GeneralRe: PHP Pin
David O'Neil6-Oct-14 15:29
professionalDavid O'Neil6-Oct-14 15:29 
GeneralRe: PHP Pin
Jeremy Falcon7-Oct-14 4:07
professionalJeremy Falcon7-Oct-14 4:07 
GeneralRe: PHP Pin
David O'Neil7-Oct-14 8:25
professionalDavid O'Neil7-Oct-14 8:25 
GeneralRe: PHP Pin
Jeremy Falcon7-Oct-14 9:32
professionalJeremy Falcon7-Oct-14 9:32 
GeneralRe: PHP Pin
Jeremy Falcon7-Oct-14 9:37
professionalJeremy Falcon7-Oct-14 9:37 
GeneralRe: PHP Pin
David O'Neil7-Oct-14 9:48
professionalDavid O'Neil7-Oct-14 9:48 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 10:29
professionalJeremy Falcon6-Oct-14 10:29 
GeneralRe: PHP Pin
Marc Clifton6-Oct-14 10:37
mvaMarc Clifton6-Oct-14 10:37 
GeneralRe: PHP Pin
Jeremy Falcon6-Oct-14 10:44
professionalJeremy Falcon6-Oct-14 10:44 
GeneralRe: PHP Pin
Marc Clifton6-Oct-14 12:38
mvaMarc Clifton6-Oct-14 12:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.