Tag: php

59 votes
17 answers
1.4K views
What is stdClass in PHP?

Please define what stdClass is.

avatar
Shantay
0 1 0 9
asked 07 September, 2021
53 votes
30 answers
2.1K views
Get the first element of an array

I have an array: array( 4 => 'apple', 7 => 'orange', 13 => 'plum' )

avatar
Corey
0 1 0 9
asked 07 September, 2021
55 votes
18 answers
3.1K views
How can I sanitize user input with PHP?

Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS att

avatar
Trudy
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
724 views
Reference - What does this error mean in PHP?

What is this? This is a number of answers about warnings, errors, and notices you might encounter while progra

avatar
Frederick
0 1 0 9
asked 07 September, 2021
66 votes
14 answers
2.5K 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

avatar
User demo
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.6K views
Enumerations on PHP

I know that PHP doesn't yet have native Enumerations. But I have become accustomed to them from the Java

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
58 votes
14 answers
2.2K views
How to Sort a Multi-dimensional Array by Value

How can I sort this array by the value of the "order" key? Even though the values are currently sequential, th

avatar
Nereida
0 1 0 9
asked 07 September, 2021
61 votes
16 answers
3K 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 this in

avatar
Keith
0 1 0 9
asked 07 September, 2021
58 votes
29 answers
572 views
"Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP

I'm running a PHP script and continue to receive errors like: Notice: Undefined variable: my_variable_na

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
56 votes
28 answers
1.8K views
How to get the client IP address in PHP

How can I get the client IP address using PHP? I want to keep record of the user who logged into my website t

avatar
User demo
0 1 0 9
asked 07 September, 2021
52 votes
11 answers
2.1K 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 bcr

avatar
Alphonso
0 1 0 9
asked 07 September, 2021
60 votes
26 answers
2K views
Difference between require, include, require_once and include_once?

In PHP: When should I use require vs. include? When should I use require_once vs. include_once?

avatar
Deedee
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
2.2K views
How do I make a redirect in PHP?

Is it possible to redirect a user to a different page through the use of PHP? Say the user goes to www.exampl

avatar
Sachiko
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
2.4K 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/st

avatar
User demo
0 1 0 9
asked 07 September, 2021
58 votes
29 answers
603 views
How do I get PHP errors to display?

I have checked my PHP ini file (php.ini) and display_errors is set and also error reporting is E_ALL. I have r

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
55 votes
23 answers
1.3K views
When should I use 'self' over '$this'?

In PHP 5, what is the difference between using self and $this? When is each appropriate?

avatar
Georgie
0 1 0 9
asked 07 September, 2021
69 votes
7 answers
1.9K 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 i

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
2.3K views
How do you parse and process HTML/XML in PHP?

How can one parse HTML/XML and extract information from it?

avatar
Robt
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
2.9K 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 Y

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
58 votes
12 answers
1.6K views