php

How to reformat multi-line comments in Eclipse PDT?

In Eclipse PDT, Ctrl-Shift-F reformats code. However, it doesn't modify comments at all. Is there some way to reformat ragged multi-line comments to 80 characters per line (or whatever)? i.e. convert // We took a breezy excursion and // gathered Jonquils from the river slopes. Sweet Marjoram grew // in luxuriant // profusion by t...

Subfolders in CodeIgniter

Hi all, I'm new to CodeIgniter and I need some help. I'd like to implement the following: View a user's profile via: http://localhost/profile/johndoe ...but administrate a user's profile via: http://localhost/admin/profile/johndoe and then be able to accomplish even further processing via: http://localhost/admin/profile/create ...and...

How do I set the Content-type in Joomla?

I am developing a Joomla component and one of the views needs to render itself as PDF. In the view, I have tried setting the content-type with the following line, but when I see the response, it is text/html anyways. header('Content-type: application/pdf'); If I do this in a regular php page, everything works as expected. It seems tha...

How to convert multiple <br/> tag to a single <br/> tag in php

Wanted to convert <br/> <br/> <br/> <br/> <br/> into <br/> ...

What is the best way to profile PHP code

I'd like to find a way to determine how long each function in PHP, and each file in PHP is taking to run. I've got an old legacy PHP application that I'm trying to find the "rough spots" in and so I'd like to locate which routines and pages are taking a very long time to load, objectively. Are there any pre-made tools that allow for t...

Is Symfony a good framework to learn?

I've never used any public framework (always used internal frameworks, or my own). I see that Symfony has a lot of tutorials and nice documentation and seems to have everything from CRUD to multiple language handling. Do you think it's a good framework to build a website that is more complicated than a blog*? If not, what is another alt...

Is there a way to have PHP print the data to a web browser in real time?

For example, if I have an echo statement, there's no guarantee that the browser might display it right away, might display a few dozen echo statements at once, and might wait until the entire page is done before displaying anything. Is there a way to have each echo appear in a browser as it is executed? ...

Parsing XML With Single Quotes?

I am currently running into a problem where an element is coming back from my xml file with a single quote in it. This is causing xml_parse to break it up into multiple chunks, example: Get Wired, You're Hired! Is then enterpreted as 'Get Wired, You' being one object, the single quote being a second, and 're Hired!' as a third. What I w...

Are PDO prepared statements sufficient to prevent SQL injection?

Let's say I have code like this: $dbh = new PDO("blahblah"); $stmt = $dbh->prepare('SELECT * FROM users where username = :username'); $stmt->execute( array(':username' => $_REQUEST['username']) ); The PDO documentation says The parameters to prepared statements don't need to be quoted; the driver handles it f...

Error handling in PHP

I'm familiar with some of the basics, but what I would like to know more about is when and why error handling (including throwing exceptions) should be used in PHP, especially on a live site or web app. Is it something that can be overused and if so, what does overuse look like? Are there cases where it shouldn't be used? Also, what are ...

Conferences/Symposiums/Courses in Britain

I see lots of advertisements for cool looking conferences based on the latest web technologies on tech-ey sites all the time, but they all seem to be based in the USA - which is too far away to justify the expense :( So, does anyone know of some cool/fun/interesting events for web developers occurring in the UK? Or any sites that would l...

How to add currency strings (non-standardized input) together in PHP?

I have a form in which people will be entering dollar values. Possible inputs: $999,999,999.99 999,999,999.99 999999999 99,999 $99,999 The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them. I tried just typecasting the strings to doubles but that didn't work. Total just equals 50...

Log/Graph PHP execution time

Are there any tools available to log the page load time for a php site? Mainly looking for something that I can see trends of load times over time, I was considering dumping them into a file using error_log(), but I don't know what I could use to parse it and display graphs ...

How do I find the mime-type of a file with php?

Ok, so I have an index.php file which has to process many different file types. how do I guess the filetype based on the REQUEST_URI. If I request http://site/image.jpg, and all requests redirect through index.php, which looks like this <?php include('/www/site'.$_SERVER['REQUEST_URI']); ?> How would I make that work correctly? ...

Best practice for placement of display logic in a view in CakePHP

I have a CakePHP 1.2 application. I'm running into the case where I need to do some logic to render things correctly in the view. Example: I have a table called Types. There are flags for various types, so each row has one or more BOOL fields set. For one type of type, I store the contents of an RTF in another field. So when I displa...

Would performance suffer using autoload in php and searching for the class file?

I've always struggled with how to best include classes into my php code. Pathing is usually an issue but a few minutes ago i found this question which dramatically helps that. Now I'm reading about __autoload and thinking that it could make the process of developing my applications much easier. The problem is i like to maintain folder st...

What are the benefits of OO programming? Will it help me write better code?

I'm a PHPer, and am not writing object-oriented code. What are the advantages of OO over procedural code, and where can I learn how to apply these ideas to PHP? ...

How to build escrow style system

I have a website where clients pay for a service but have to out the money upfront via escrow, I'm very proficient with PHP (this is what the website is coded in) how would I go about implementing an escrow system that would work automatically? ...

Can PHP's SQL Server driver return SQL return codes?

Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver. mssql_get_last_message() always returns nothing, and I'm thinking it's because it only returns the very last line...

How can I get PHP's simplicity but Perl's power?

I despise the PHP language, and I'm quite certain that I'm not alone. But the great thing about PHP is the way that mod_php takes and hides the gory details of integrating with the apache runtime, and achieves CGI-like request isolation and decent performance. What's the shortest-distance approach to getting the same simplicity, speed ...