|
You're having the same motive as I had, when I wrote Why Use ASP.NET for Web Development[^] but just a little bit more aggression.
Favourite line: Throw me to them wolves and close the gate up. I am afraid of what will happen to them wolves - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: You're having the same motive as I had,
I like your PHP example adding two integers.
Marc
|
|
|
|
|
Marc Clifton wrote: I like your PHP example adding two integers.
Loose types are perfect for the web though. His example is just his bias. I could give tons more examples where PHP is much much much more cleaner than C# when converting types, which a lot of programs have to deal with, especially if using more than one input or output stream (like the web).
Would I prefer a strong type in PHP? I would. Is it nearly as big a deal as people that never use PHP make it out to be? Not at all. In years of using PHP I've only had a handful of issues arise from loose types.
Jeremy Falcon
|
|
|
|
|
When you wrote "silent exits" I thought you were ranting about Ruby for a moment.
cheers
Chris Maunder
|
|
|
|
|
Chris Maunder wrote: When you wrote "silent exits" I thought you were ranting about Ruby for a moment.
Touche.
Marc
|
|
|
|
|
Aw, quit "Graus"ing about it...
Will Rogers never met me.
|
|
|
|
|
So now the poor man has his own verb?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
|
|
|
|
|
Jeremy Falcon
|
|
|
|
|
I realize this is just a good old fashioned rant, but most of your gripes have to do with not knowing the language man. Plain and simple. Now, PHP is not the most modern language in the world, gotta give you that, but it has a LOT of functionality and runs on a lot of platforms. I mean a lot. It's still pretty dang speedy too. In this little place called reality, that's more important than hating it because of using $ to denote a scalar variable.
But hey, totally awesome rant nonetheless.
I'd also stay away from Perl if you don't like PHP. Fair warning.
Jeremy Falcon
|
|
|
|
|
|
Yup, so I know it pretty well. It has some "wtf" things about it, but it's not nearly as bad as the people on CP that never use it make it out to seem. But in all fairness, it's not a modern language.
Jeremy Falcon
|
|
|
|
|
I thought so. So far you were the only one who defended it, I think.
I used to code a lot in Perl, so I am familiar with weird syntax, also. Although I absolutely hate working with Perl, it still is very powerful and is still a valid and relevant tool.
|
|
|
|
|
Slacker007 wrote: I used to code a lot in Perl, so I am familiar with weird syntax, also. Although I absolutely hate working with Perl, it still is very powerful and is still a valid and relevant tool.
Totally agree. Same thing with regex. It looks like someone took code and put it in a blender, and yet I'm still very glad we have it because of its flexibility when quickly writing searches in comparison to manually coding one.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: but it has a LOT of functionality and runs on a lot of platforms.
In that, I agree. There is a simple elegance to it, I just wish there was some tool out there that did a Lint or equivalent to find all my stupid mistakes, like passing in $foo and using it like $foos.
Jeremy Falcon wrote: because of using $ to denote a scalar variable.
Wait, I don't have to use the $? I thought it was intended to make it clear this isn't a function definition. Regardless, me noob.
As a lightweight scripting language, it looks like it carries a lot less baggage than other things I've seen.
Jeremy Falcon wrote: But hey, totally awesome rant nonetheless.
I aim to please.
Marc
|
|
|
|
|
Marc Clifton wrote: Wait, I don't have to use the $? I thought it was intended to make it clear this isn't a function definition.
The short answer is, you gotta use it.
Marc Clifton wrote: I just wish there was some tool out there that did a Lint or equivalent to find all my stupid mistakes, like passing in $foo and using it like $foos.
This is the biggest problem for the language, they're out there. But the only out-of-the-box solutions like you get with VS aren't free. Even still, there's some configuration that must take place.
Just the Unix-y way of life man. Microsoft excels at ease of use, Unix/Linux says piss off n00b unless you RTFM.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: Unix/Linux says piss off n00b unless you pound your brains into a bloody pulp R(ing)TFM, and don't catch the endless exceptions to the rules, because we never F'ing documented them for you! And if we did, we put them in some obscure location that is only findable after your exposed brain stem smashes through the screen, triggering an epileptic-like seizure that miraculously moves your fingers into an archaic 'man' command line sequence that infinite monkeys could never reproduce.
FTFY
|
|
|
|
|
Touché.
Seriously though, the docs are out there, they just tend to be more decentralized than say MSDN. I found it's the same thing with learning wxWidgets too, part of the pain was just finding good documentation online. Open source drawback I suppose, everyone wants to code, nobody wants to write docs.
If I were just starting out with PHP and *nix these days, I'd totally be pouring myself into books at the very least to help the learning curve.
Jeremy Falcon
|
|
|
|
|
My frustration with their mentality is that the barrier to entry is too high, like you pointed out. I once had to change a password for a MySQL database, so I followed the instructions here[^]. Note the "'" (single quote) surrounding the password. Since I was doing it from a Windows command prompt there was a whole other level nobody mentioned. Doing it that way actually entered " ' "s in the password! And logging in became impossible. So changing the password was the only option, once I figured out what the issue was (at least fifteen minutes of "OH SH*T, WHAT DID I DO???")
Then there were four more hours ahead of me, because of a single friggin space! None of the examples online showed that the correct command is "mysqladmin -u root -p'xyz123' password newPassword". Note the lack of space between the "p" and the " ' ". I wanted to kill... And that wasn't my first exposure to their stuff.
I'm not afraid of command prompts, having once helped administer a Windows/Solaris hybrid network, but issues like the previous are far too abundant in that world. I want to actually get something done on my computer, not dig through documentation all day.
|
|
|
|
|
David O'Neil wrote: Then there were four more hours ahead of me, because of a single friggin space! None of the examples online showed that the correct command is "mysqladmin -u root -p'xyz123' password newPassword". Note the lack of space between the "p" and the " ' ". I wanted to kill... And that wasn't my first exposure to their stuff.
Oh yeah, that totally annoyed me too. At one point I read there was some technical reason for it, but at the end of the day I suspect that's a load of BS.
David O'Neil wrote: I'm not afraid of command prompts, having once helped administer a Windows/Solaris hybrid network, but issues like the previous are far too abundant in that world. I want to actually get something done on my computer, not dig through documentation all day.
Fair enough, but just about any environment has its quirks. Although I don't have many examples I can think of off the top of my head (old age tends to do that), it still 'tis be true.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: (old age tends to do that)
I wasn't going to say that the network involved Windows for Workgroups.... , so I know the aging feeling.
PS - If you ever have a moment, and care to give some feedback on PHP code, how could this program[^] be improved? That was a self-teaching marathon, having never really touched PHP before, and I'm certain there are probably many tricks I missed, and language issues that could be improved, but the end product seems to work. Thanks. (If not, no problem.)
|
|
|
|
|
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.
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.
$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...
if(isset($_POST['txn_id']))
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.
$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
|
|
|
|
|
Thanks! I'll change it up, and update the article in the next week or so with the improvements, with more thanks at that time!
|
|
|
|
|
Oh, one more (quick?) question, if I may. So this:
Quote: require_once BASE_PATH . 'my/relative/path.php';
would become something like this:
Quote: require_once BASE_PATH . '/home/user/phpPayPalController.php'
and exposing it that way (because anyone can look at the html for the landing page, which has to have that on it) doesn't make it easier to hack the db password and setup files that are at that protected subdirectory location?
Thanks!
|
|
|
|
|
Let's assume you have a PHP file in /home/myapp/myfile.php . Then BASE_PATH would end up being /home/myapp/ at this point. So you'd want to do do something like require_once BASE_PATH . 'myfile.php'; . Whereas before it was just require_once 'myfile.php'; . However, this way the file will be included regardless of how the script is executed.
Jeremy Falcon
|
|
|
|
|
Oh. OK. That means since the main entry file is an html page, visible onsite, the base path would be it, and the require_once would be something like require_once BASE_PATH . '../../../myFile.php'; , depending upon how many subdirectories it was above the directory. Thanks.
|
|
|
|