LMSouq

Knowledge Base

Browse Moodle Solutions

2108 solutions found

Page 25 of 106
0 votes
1 ans
3 views
PHP short-ternary ("Elvis") operator vs null coalescing operator

Can someone explain the differences between [ternary operator shorthand](https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comp...

php-dev Solved
BA
asked 1 month ago by balping
0 votes
1 ans
3 views
What is the difference between HTTP_HOST and SERVER_NAME in PHP?

What is the difference between `$_SERVER['HTTP_HOST']` and `$_SERVER['SERVER_NAME']` in PHP? When would you consider using one over the other...

server-admin Solved
EM
asked 1 month ago by Emanuil Rusev
0 votes
1 ans
3 views
How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

What is the difference between `==` and `===`? - How exactly does the loosely `==` comparison work? - How exactly does the strict `===` comparison work?...

php-dev Solved
NI
asked 1 month ago by nickf
0 votes
1 ans
3 views
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 PH...

php-dev Solved
ST
asked 1 month ago by streetparade
0 votes
1 ans
3 views
NOW() function in PHP

Is there a PHP function that returns the date and time in the same format as the MySQL function `NOW()`? I know how to do it using `date()`, but I am asking...

php-dev Solved
MO
asked 1 month ago by MoeAmine
0 votes
1 ans
3 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.example.com/page.php` and I want to redirect them to...

php-dev Solved
SA
asked 1 month ago by Sam
0 votes
1 ans
3 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 through his/her IP address.

php-dev Solved
AN
asked 1 month ago by Anup Prakash
0 votes
1 ans
3 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 programming PHP and have no clue how to fix them....

php-dev Solved
HA
asked 1 month ago by hakre
0 votes
1 ans
3 views
How do I get the current date and time in PHP?

Which PHP function can return the current date/time?

php-dev Solved
MI
asked 1 month ago by Mike
0 votes
1 ans
3 views
Remove empty array elements

Some elements in my array are empty strings from users. `$linksArray` still has empty elements after the following: foreach($linksArray as $link) {...

php-dev Solved
WI
asked 1 month ago by Will
0 votes
1 ans
3 views
PHP random string generator

I'm trying to create a randomized string in PHP, and I get absolutely no output with this: <?php function RandomString() {...

php-dev Solved
CA
asked 1 month ago by Captain Lightning
0 votes
1 ans
3 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 using arrays. I'd like a quick-and-dirty functi...

php-dev Solved
HA
asked 1 month ago by Haroldo
0 votes
1 ans
3 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 difference between these packages?

php-dev Solved
O.
asked 1 month ago by O..
0 votes
1 ans
3 views
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...

php-dev Solved
DI
asked 1 month ago by DiegoP.
0 votes
1 ans
3 views
How do I convert a string to a number in PHP?

I want to convert these types of values, `'3'`, `'2.34'`, `'0.234343'`, etc. to a number. In JavaScript we can use `Number()`, but is th...

php-dev Solved
SA
asked 1 month ago by Sara
0 votes
1 ans
3 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 double quotes. I just know in .NET, or the C langua...

php-dev Solved
RO
asked 1 month ago by rob waminal
0 votes
1 ans
3 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 fairly efficient way to check if an array *"is a l...

php-dev Solved
WI
asked 1 month ago by Wilco
0 votes
1 ans
3 views
How can I get a file's extension in PHP?

This is a question you can read everywhere on the web with various answers: $ext = end(explode('.', $filename)); $ext = substr(strrchr($file...

php-dev Solved
BI
asked 1 month ago by Bite code
0 votes
2 ans
3 views
How do I get the query builder to output its raw SQL query as a string?

Given the following code: <!-- language: lang-php --> DB::table('users')->get(); I want to get the raw SQL query string that the d...

database Solved
ME
asked 1 month ago by meiryo
0 votes
1 ans
3 views
Remove trailing delimiting character from a delimited string

What is fastest way to remove the last character from a string? I have a string like a,b,c,d,e, I would like to remove the last ',' and get...

php-dev Solved
I-
asked 1 month ago by I-M-JM