|
I've been writing PHP for my job for over a year now, and we don't use a framework. I'm going to recommend two tools that make using PHP less messy. The first is Smarty, a templating language for PHP. It's overkill for small projects, but if you're working on something bigger than one page, it can really help you avoid poo poo like "echo '<html><head>...'". If you've ever hated mixing a ton of PHP code in with gigantic blocks of HTML, you'll probably want to try Smarty. The second tool is MDB2. It's a database abstraction layer, and it has a ton of drivers, including PostgreSQL, Oracle, MSSQL, and MySQL. If you use its built in prepare and execute methods, it will escape data for you, which is very handy. Another positive feature is that it will help you avoid the multitude of mysql_real_add_slashes_im_serious_this_time_i_mean_it methods. I'm also a fan of its placeholder functions, which some databases don't support natively. Also, if you can, turn off magic quotes. It still comes turned on by default and the only thing that's magic about it is how much it pisses people off.
|
# ¿ Mar 20, 2008 07:14 |
|
|
# ¿ Apr 29, 2024 15:54 |
|
Scarboy posted:Isn't PHP a good enough templating language that you shouldn't have to use another one? What's wrong with: It does a little more than that, it has built in validation, pagination, it auto-generates drop-down menus, radio groups, checkbox groups as well as templating. I know it seems kinda goofy to have a templating language inside of a templating language at first, but I really like it.
|
# ¿ Mar 20, 2008 07:31 |
|
Grigori Rasputin posted:Also, is using URL arguments like this the preferred way to communicate between pages? It's very easy to do, but I wasn't sure if there was a better way. This is really a broad question. Data sharing between pages can be done in a lot of different ways, but it really depends on what you're trying to do. If you're trying to make a form of sign-on system, the most common way to go about that would be to store some info in a session file server-side (PHP does this via session_start and $_SESSION), then have your pages check for the given session info that you set when the user logged in. When it comes down to accessing info, such as a page to edit a user's profile page, using the query string is the way to go. It would be something like profile.php?profile=blah, which would contain a form that submits to itself via POST. When it comes down to it, I'm just arguing for normal usage of GET and POST -- GET is used to access resources non-destructively, POST is used to modify them. All I really try to do is use the HTTP methods for what they were designed to do in the basic sense, but I'm straying off topic so I'll stop there. I hope this helps you out
|
# ¿ May 24, 2008 13:51 |
|
The1ManMoshPit posted:PHP loads a copy of the file into memory once for every request coming in even though I am returning the exact same file for each of these requests. This quickly overwhelms the server if a large number of requests come in simultaneously. Ideally there would be some way for me to just have the file loaded into memory already and have each instance of the script just read and output straight out of that memory. Are you running against Apache? If so, do you have the ability to install new Apache modules? If so, give mod_xsendfile a try. This module offloads the actual serving of the file to the web server. Instead of reading the file and and outputting its contents, all your script has to do is emit a few headers.
|
# ¿ Jan 21, 2010 04:47 |
|
Elias_Maluco posted:So I have this site thatīs basically an extranet where users will login and download some files. Are you using Apache? If so, give mod_xsendfile a try. nginx and lighttpd have this as well. If you can't use this module for whatever reason, you can always read the file in chunks and echo the chunks one at a time instead. Xenos fucked around with this message at 14:28 on Mar 25, 2011 |
# ¿ Mar 25, 2011 14:26 |