Join us in building a kind, collaborative learning community via our updatedCode of Conduct.

Questions tagged [php]

PHP is a widely used, high-level, dynamic, object-oriented and interpreted scripting language primarily designed for server-side web development.

3802
votes
18answers
541k views

Reference — What does this symbol mean in PHP?

What is this?This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list. ...
2781
votes
28answers
1.4m views

How can I prevent SQL injection in PHP?

If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example:$unsafe_variable=$_POST['user_input']; ...
2668
votes
36answers
3.6m views

How do I check if a string contains a specific word?

Consider:$a='How are you?';if ($a contains 'are')echo 'true';Suppose I have the code above, what is the correct way to write the statement if ($a contains 'are')?
2201
votes
14answers
182k views

Why shouldn't I use mysql_* functions in PHP?

What are the technical reasons for why one shouldn't use mysql_* functions? (e.g. mysql_query(), mysql_connect() or mysql_real_escape_string())?Why should I use something else even if they work on ...
2028
votes
29answers
1.4m views

How do I get a YouTube video thumbnail from the YouTube API?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?
1977
votes
34answers
2.0m views

PHP: Delete an element from an array

Is there an easy way to delete an element from an array using PHP, such that foreach ($array) no longer includes that element?I thought that setting it to null would do it, but apparently it does ...
1902
votes
28answers
361k views

How do you parse and process HTML/XML in PHP?

How can one parse HTML/XML and extract information from it?
1781
votes
22answers
612k views

When to use self over $this?

In PHP 5, what is the difference between using self and $this?When is each appropriate?
1649
votes
7answers
336k views

How does PHP 'foreach' actually work?

Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don't want any answers along the lines of "this is how you ...
1397
votes
30answers
751k views

Convert HTML + CSS to PDF with PHP? [closed]

I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7. It uses fairly basic CSS to style it and renders fine in HTML.I'm now after a way of converting it to PDF. I have tried:...
1312
votes
24answers
2.3m views

How do I get PHP errors to display?

I have checked my PHP ini file and display errors is set and also error reporting is E_ALL. I have restarted my Apache web server.I have even put these lines at the top of my script, and it doesn't ...
1221
votes
30answers
703k views

startsWith() and endsWith() functions in PHP

How can I write two functions that would take a string and return if it starts with the specified character/string or ends with it?For example:$str='|apples}';echo startsWith($str, '|'); //...
1148
votes
9answers
334k views

How do you use bcrypt for hashing passwords in PHP?

Every now and then I hear the advice "Use bcrypt for storing passwords in PHP, bcrypt rules".But what is bcrypt? PHP doesn't offer any such functions, Wikipedia babbles about a file-encryption ...
1049
votes
14answers
189k views

Secure hash and salt for PHP passwords

It is currently said that MD5 is partially unsafe. Taking this into consideration, I'd like to know which mechanism to use for password protection.This question, Is “double hashing” a password less ...
994
votes
14answers
123k views

UTF-8 all the way through

I'm setting up a new server, and want to support UTF-8 fully in my web application. I have tried in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.Where ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,