php

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

57 votes
30 answers
2.6K views
How to check if PHP array is associative or sequential?

PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fair

avatar
Gigi
0 1 0 9
asked 07 September, 2021
59 votes
4 answers
1.7K views
What is thread safe or non-thread safe in PHP?

I saw different binaries for PHP, like non-thread or thread safe? What does this mean? What is the differen

avatar
Basil
0 1 0 9
asked 07 September, 2021
59 votes
7 answers
2.3K views
What is the difference between single-quoted and double-quoted strings in PHP?

I'm a little confused why I see some code in PHP with string placed in single quotes and sometimes in dou

avatar
Jeff
0 1 0 9
asked 07 September, 2021
64 votes
30 answers
2.5K views
Convert a PHP object to an associative array

I'm integrating an API to my website which works with data stored in objects while my code is written usi

avatar
Jeff
0 1 0 9
asked 07 September, 2021
52 votes
27 answers
771 views
Remove empty array elements

Some elements in my array are empty strings based on what the user has submitted. I need to remove those eleme

avatar
Lynette
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
581 views
PHP random string generator

I'm trying to create a randomized string in PHP, and I get absolutely no output with this: <?php

avatar
Janella
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
1.3K views
How do I get the current date and time in PHP?

Which PHP function can return the current date/time?

avatar
Lynette
0 1 0 9
asked 07 September, 2021
54 votes
10 answers
1.7K views
How can I do &apos;insert if not exists&apos; in MySQL?

I started by googling and found the article How to write INSERT if NOT EXISTS queries in standard SQL which ta

avatar
Bryan
0 1 0 9
asked 07 September, 2021
53 votes
14 answers
2.9K views
Where can I find php.ini?

A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz's and

avatar
Omar
0 1 0 9
asked 07 September, 2021
53 votes
28 answers
389 views
Get the full URL in PHP

avatar
Sachiko
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
1.6K views
mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc... expects parameter 1 to be resource

I am trying to select data from a MySQL table, but I get one of the following error messages: mysql_fetch_

avatar
Boyd
0 1 0 9
asked 07 September, 2021
55 votes
19 answers
1.1K views
Returning JSON from a PHP Script

I want to return JSON from a PHP script. Do I just echo the result? Do I have to set the Content-Type header?

avatar
Gigi
0 1 0 9
asked 07 September, 2021
52 votes
20 answers
1.3K views
PHP array delete by value (not key)

I have a PHP array as follows: $messages = [312, 401, 1599, 3, ...]; I want to delete the element containin

avatar
Serina
0 1 0 9
asked 07 September, 2021
56 votes
13 answers
1.1K views
Detecting request type in PHP (GET, POST, PUT or DELETE)

How can I detect which request type was used (GET, POST, PUT or DELETE) in PHP?

avatar
Omar
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
1K views
How do I use PHP to get the current year?

I want to put a copyright notice in the footer of a web site, but I think it's incredibly tacky for the y

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
52 votes
17 answers
1.5K views
What is the difference between public, private, and protected?

When and why should I use public, private, and protected functions and variables inside a class? What is the d

avatar
Nidia
0 1 0 9
asked 07 September, 2021
65 votes
4 answers
1.8K views
What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

I have tried reading some articles, but I am not very clear on the concepts yet. Would someone like to take a

avatar
Wei
0 1 0 9
asked 07 September, 2021
59 votes
17 answers
357 views
How do I expire a PHP session after 30 minutes?

I need to keep a session alive for 30 minutes and then destroy it.

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
59 votes
17 answers
1.3K 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
2K 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