LMSouq

Knowledge Base

Browse Moodle Solutions

2108 solutions found

Page 19 of 106
0 votes
1 ans
3 views
How to run single test method with phpunit?

I am struggling to run a single test method named `testSaveAndDrop` in the file `escalation/EscalationGroupTest.php` with `phpunit`. I tried the following combi...

php-dev Solved
AL
asked 1 month ago by Alex
0 votes
1 ans
3 views
How to define an empty object in PHP

with a new array I do this: $aVal = array(); $aVal[key1][var1] = "something"; $aVal[key1][var2] = "something else";...

php-dev Solved
ED
asked 1 month ago by ed209
0 votes
1 ans
3 views
How can one use multi threading in PHP applications

Is there a realistic way of implementing a multi-threaded model in PHP whether truly, or just simulating it. Some time back it was suggested that you could forc...

php-dev Solved
ST
asked 1 month ago by Steve Obbayi
0 votes
1 ans
3 views
How to find the last day of the month from date?

How can I get the last day of the month in PHP? Given: $a_date = "2009-11-23" I want 2009-11-30; and given $a_date = "2009-12...

general-dev Solved
MI
asked 1 month ago by Mithun Sreedharan
0 votes
1 ans
3 views
How to create a newline character?

In PHP I am trying to create a newline character: echo $clientid; echo ' '; echo $lastname; echo ' '; echo '\r\n&...

general-dev Solved
DA
asked 1 month ago by davidjhp
0 votes
1 ans
3 views
What is a Python equivalent of PHP's var_dump()?

When debugging in PHP, I frequently find it useful to simply stick a [var_dump()][1] in my code to show me what a variable is, what its value is, and the same f...

php-dev Solved
ZO
asked 1 month ago by Zoredache
0 votes
1 ans
3 views
How to generate a random, unique, alphanumeric string?

How would it be possible to generate a random, unique string using numbers and letters for use in a verify link? Like when you create an account on a website, a...

php-dev Solved
AN
asked 1 month ago by Andrew
0 votes
1 ans
3 views
How can I find the php.ini file used by the command line?

I need to enable *pdo_mysql* in my [EasyPHP][1] environment, so I went to the *php.ini* file and uncommented the following line: extension=php_pdo_mysql....

php-dev Solved
AM
asked 1 month ago by Amokrane Chentir
0 votes
1 ans
3 views
Use json_decode() to create array insead of an object

I am trying to decode a JSON string into an array but i get the following error. > Fatal error: Cannot use object of type stdClass as array Here is the...

php-dev Solved
HA
asked 1 month ago by Harsha M V
0 votes
1 ans
3 views
In PHP, what is a closure and why does it use the "use" identifier?

I'm checking out some `PHP 5.3.0` features and ran across some code on the site that looks quite funny: public function getTotal($tax) {...

php-dev Solved
SE
asked 1 month ago by SeanDowney
0 votes
1 ans
3 views
How to loop through PHP object with dynamic keys

I tried to parse a JSON file using PHP. But I am stuck now. This is the content of my JSON file: ```json { "John": { "status":&q...

php-dev Solved
JO
asked 1 month ago by John Doe
0 votes
1 ans
3 views
Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)

I am on shared hosting and have [cPanel][1], Apache, and PHP is run by [FastCGI][2]. Where does PHP store the error log? Is there another way I can find the...

server-admin Solved
PH
asked 1 month ago by PHPLOVER
0 votes
1 ans
3 views
How can I perform static code analysis in PHP?

Is there a static analysis tool for PHP source files? The binary itself can check for syntax errors, but I'm looking for something that does more, like:...

php-dev Solved
ES
asked 1 month ago by eswald
0 votes
1 ans
3 views
How to override trait function and call it from the overridden function?

Scenario: trait A { function calc($v) { return $v+1; } } class MyClass { use A;...

php-dev Solved
SH
asked 1 month ago by Shu
0 votes
1 ans
3 views
PHP cURL custom headers

I'm wondering if/how you can add custom headers to a cURL HTTP request in PHP. I'm trying to emulate how iTunes grabs artwork and it uses these non-stan...

php-dev Solved
12
asked 1 month ago by 123
0 votes
1 ans
3 views
PHPUnit assert that an exception was thrown?

Does anyone know whether there is an `assert` or something like that which can test whether an exception was thrown in the code being tested?

php-dev Solved
FE
asked 1 month ago by Felipe
0 votes
1 ans
3 views
Fatal error: Maximum execution time of 30 seconds exceeded

I am downloading a JSON file from an online source and and when it runs through the loop I am getting this error: > Fatal error: Maximum execution time of...

general-dev Solved
HA
asked 1 month ago by Harsha M V
0 votes
1 ans
3 views
How to convert string to boolean php

How can I convert string to `boolean`? $string = 'false'; $test_mode_mail = settype($string, 'boolean'); var_dump($...

php-dev Solved
RU
asked 1 month ago by Run
0 votes
1 ans
3 views
Get the first level key of the first row containing a specified column value in a 2d array

I have an array where I want to search the `uid` and get the key of the array. ## Examples Assume we have the following 2-dimensional array: $userdb...

php-dev Solved
RA
asked 1 month ago by Rachit
0 votes
1 ans
3 views
Showing all errors and warnings

**UPDATE 2:** I have now removed the following from the .php file: <?php error_reporting( E_ALL ); ?> I have set display_erros in php.ini as...

general-dev Solved
OS
asked 1 month ago by oshirowanen