50 Answered Questions for the topic PHP

Php

08/26/19

Which Game Servers Hosting Control Panel is the best?

Php

07/29/19

Which back-end web programming language to use?

I have a project where I will be collaborating to build a fairly simple site with some database access. I will be doing the back-end work, and my colleague will be doing the web design. The problem... more
Php

07/29/19

How can I team up two MVC frameworks without having them fight each other?

I'm creating a CRUD-based web project, and am thinking about using a server side MVC framework (such as CodeIgniter or Laravel) in tandem with a client side MVC framework (such as AngularJS). Is... more
Php

07/29/19

PHP: when to use arrays, and when to use objects for mostly-data-storing code constructs?

PHP is a mixed paradigm language, allowing to use and return non-object data types, such as arrays. I pose a question to try to clarify some guidelines for selection of arrays vs objects when... more
Php

07/29/19

Is dynamic language always interpreted?

Looking at most (if not all) dynamic languages [i.e Python, PHP, Perl and Ruby], they are all interpreted. Correct me if I'm wrong. Is there any example of dynamic language that goes through... more
Php

06/19/19

What should be passed into if() to print 'Hello World'?

What should be passed into the if() to print the output as "Hello World"? [Note: It should execute the else block.] if(?){ } else { echo "World"; }
Php

06/19/19

unusual ternary operation?

I was asked to perform this operation of ternary operator use: $test='one'; echo $test == 'one' ? 'one' : $test == 'two' ? 'two' : 'three'; Which prints two (checked using php). I am still... more
Php

06/05/19

Where is my php.ini file located on the server?

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 built them as instructed (instead of rpms and what-have-you). And all was fine. Today I... more
Php

06/05/19

What is the difference between public, private, and protected in PHP?

When and why should I use `public`, `private`, and `protected` functions and variables inside a class? What is the difference between them? Examples: // Public public $variable; public... more
Php

06/05/19

Show a number to 2 decimal places?

What's the correct way to round a PHP string to 2 decimal places? $number = "520"; // It's a string from a DB $formatted_number = round_to_2dp($number); echo $formatted_number; The... more
Php

06/05/19

How can I parse a JSON file with PHP?

I tried to parse a JSON file using PHP. But I am stuck now. This is the content of my JSON file: { "John": { "status":"Wait" }, "Jennifer": { "status":"Active" }, ... more
Php

06/04/19

How to determine the first and last iteration in a foreach loop?

The question is simple. I have a `foreach` loop in my code: foreach($array as $element) { //code } In this loop, I want to react differently when we are in first or last iteration. How... more
Php

06/03/19

Is there a function to make a copy of a PHP array to another?

Is there a function to make a copy of a PHP array to another? I have been burned a few times trying to copy PHP arrays. I want to copy an array defined inside an object to a global outside it.
Php

06/02/19

how to get the last char of a string in PHP?

I need to get the last character of a string. Say I have "testers" as input string and I want the result to be "s". how can I do that in PHP?
Php

06/01/19

How to get useful error messages in PHP?

I find programming in PHP quite frustrating. Quite often I will try and run the script and just get a blank screen back. No error message, just empty screen. The cause might have been a simple... more
Php

05/29/19

Insert new item in array on any position in PHP?

How can I insert a new item into an array on any position, for example in the middle of array?
Php

05/29/19

How to parse a string of boolean logic in PHP?

I'm building a PHP class with a private member function that returns a string value such as: 'true && true || false' to a public member function. (This string is the result of some regex... more
Php

05/29/19

How to perform an action every 5 results?

How can I perform an action within a `for` loop every 5 results? Basically I'm just trying to emulate a table with 5 columns.
Php

05/28/19

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 difference between these packages?
Php

05/28/19

Get the full URL in PHP?

I use this code to get the full URL: $actual_link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; The problem is that I use some masks in my `.htaccess`, so what we see in the URL is... more
Php

05/28/19

Why would one omit the close tag?

I keep reading it is poor practice to use the PHP close tag `?>` at the end of the file. The header problem seems irrelevant in the following context (and this is the only good argument so far):... more
Php

05/28/19

How do I catch a PHP Fatal Error?

I can use `set_error_handler()` to catch most PHP errors, but it doesn't work for fatal (`E_ERROR`) errors, such as calling a function that doesn't exist. Is there another way to catch these... more
Php

05/28/19

What is the point of interfaces in PHP?

Interfaces allow you to create code which defines the methods of classes that implement it. You cannot however add any code to those methods. Abstract classes allow you to do the same thing, along... more
Php

05/28/19

How do I send a POST request with PHP?

Actually I want to read the contents that come after the search query, when it is done. The problem is that the URL only accepts `POST` methods, and it does not take any action with `GET`... more
Php

05/26/19

Is there an easy way to delete an element from an array using PHP?

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... more
1

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.