LMSouq

Knowledge Base

Browse Moodle Solutions

Clear

366 solutions found in php-dev

Page 1 of 19
0 votes
1 ans
4 views
Curly braces in string in PHP

What is the meaning of `{ }` (curly braces) in string literals in PHP?

php-dev Solved
RE
asked 1 month ago by redcoder
0 votes
1 ans
4 views
PHP Pass variable to next page

It seems pretty simple but I can't find a good way to do it. Say in the first page I create a variable $myVariable = "Some text"; And...

php-dev Solved
CA
asked 1 month ago by Carlo
0 votes
1 ans
4 views
php is null when empty?

I have a question regarding `NULL` in PHP: $a = ''; if($a == NULL) { echo 'is null'; } Why do I see **is nu...

php-dev Solved
ER
asked 1 month ago by Erin Tucker
0 votes
1 ans
4 views
How to output in CLI during execution of PHP Unit tests?

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things. I have tried the following (similar to the [PHPUnit Man...

php-dev Solved
JE
asked 1 month ago by Jess Telford
0 votes
1 ans
3 views
PHP function overloading

Coming from C++ background ;) How can I overload PHP functions? One function definition if there are any arguments, and another if there are no argument...

php-dev Solved
VA
asked 1 month ago by Vamsi Krishna B
0 votes
1 ans
3 views
How to call a JavaScript function from PHP?

How to call a JavaScript function from PHP? <?php jsfunction(); // or echo(jsfunction()); // or // Anything e...

php-dev Solved
ZE
asked 1 month ago by Zeeshan Rang
0 votes
1 ans
3 views
How can I easily switch between PHP versions on Mac OSX?

I would like to test my application on PHP 5.3 up to PHP 8.2. Where and how can I install the versions and how can I switch them by running a small script?...

php-dev Solved
XA
asked 1 month ago by Xaver
0 votes
1 ans
3 views
What are the advantages of using getters and setters instead of functions or simply public fields in PHP?

I'm not a PHP developer, so I'm wondering what the advantages and disadvantages are in PHP to using explicit getter/setters, in a pure OOP style, with p...

php-dev Solved
MA
asked 1 month ago by Mark
0 votes
1 ans
3 views
php Replacing multiple spaces with a single space

I'm trying to replace multiple spaces with a single space. When I use `ereg_replace`, I get an error about it being deprecated. ereg_replace("[...

php-dev Solved
DA
asked 1 month ago by Dani
0 votes
1 ans
3 views
Explode string on commas and trim potential spaces from each value

For example, I would like to create an array from the elements in this string: $str = 'red, green, blue ,orange'; I know you can e...

php-dev Solved
SE
asked 1 month ago by SeanWM
0 votes
1 ans
3 views
PHP Get Site URL Protocol - http vs https

I've written a little function to establish the current site url protocol but I don't have SSL and don't know how to test if it works under https. *...

php-dev Solved
AN
asked 1 month ago by anon445699
0 votes
1 ans
3 views
What's the difference between :: (double colon) and -> (arrow) in PHP?

There are two distinct ways to access methods in PHP, but what's the difference? $response->setParameter('foo', 'bar'); and...

php-dev Solved
JO
asked 1 month ago by Joe
0 votes
1 ans
3 views
How can I remove a key and its value from an associative array?

Given an associative array: array("key1" => "value1", "key2" => "value2", ...) How would I go about remo...

php-dev Solved
GS
asked 1 month ago by gsquare567
0 votes
1 ans
3 views
How can I check if a URL exists via PHP?

How do I check if a URL exists (not 404) in PHP?

php-dev Solved
X1
asked 1 month ago by X10nD
0 votes
1 ans
3 views
Merging two arrays with the "+" (array union operator) How does it work?

I have some code that appears to merge the data from two arrays using `+=`, but it doesn't include all of the elements in the element. How does it work?...

php-dev Solved
US
asked 1 month ago by user198729
0 votes
1 ans
3 views
How to fix error with xml2-config not found when installing PHP from sources?

When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php) and I run `./configu...

php-dev Solved
TR
asked 1 month ago by TroodoN-Mike
0 votes
1 ans
3 views
Using dynamic variable names in PHP

I'm trying to use dynamic variable names. So inside this loop I want to create `$file0`, `$file1`, and `$file2`: for($i=0; $i<=2; $i++) {...

php-dev Solved
US
asked 1 month ago by user1159454
0 votes
1 ans
3 views
How can I output a UTF-8 CSV in PHP that Excel will read properly?

I've got this very simple thing that just outputs some stuff in CSV format, but it's got to be UTF-8. I open this file in TextEdit or TextMate or Dreamw...

php-dev Solved
BE
asked 1 month ago by Ben Saufley
0 votes
1 ans
3 views
Find the last element of an array while using a foreach loop in PHP

I am writing a SQL query creator using some parameters. In Java, it's very easy to detect the last element of an array from inside the for loop by just chec...

php-dev Solved
VA
asked 1 month ago by Vaibhav Kamble
0 votes
1 ans
3 views
How to increase maximum execution time in php

I want to increase *maximum execution time* in php , not by changing `php.ini` file. I want to Increase it from my php file. Is this possible?

php-dev Solved
PR
asked 1 month ago by Pritesh Mahajan