LMSouq

Knowledge Base

Browse Moodle Solutions

2108 solutions found

Page 20 of 106
0 votes
1 ans
3 views
Can't use method return value in write context

I would think the following piece of code should work, but it doesn't **(Edited: Now works in PHP 5.5+)**: if (!empty($r->getError())) Where `g...

general-dev Solved
EX
asked 1 month ago by Extrakun
0 votes
1 ans
3 views
PHPDoc type hinting for array of objects?

So, in PHPDoc one can specify `@var` above the member variable declaration to hint at its type. Then an IDE, for ex. PHPEd, will know what type of object it&#39...

php-dev Solved
AR
asked 1 month ago by Artem Russakovskii
0 votes
1 ans
3 views
How to filter an associative array comparing keys with values in an indexed array?

The callback function in [`array_filter()`][1] only passes in the array's values, not the keys. If I have: $my_array = array("foo" =...

database Solved
MA
asked 1 month ago by maček
0 votes
1 ans
3 views
How to push both value and key into PHP array

Take a look at this code: $GET = array(); $key = 'one=1'; $rule = explode('=', $key); /* array_push($GET, $rule[0] =&g...

php-dev Solved
GA
asked 1 month ago by Gal
0 votes
1 ans
3 views
Call to undefined function curl_init()?

When i am going to implement Authorize.net payment gateway. However, I got this error: > Call to undefined function curl_init() Please let me know wha...

php-dev Solved
PR
asked 1 month ago by Pramod Kumar Sharma
0 votes
1 ans
3 views
Laravel requires the Mcrypt PHP extension

I am trying to use the `migrate` function in Laravel 4 on OSX. However, I am getting the following error: Laravel requires the Mcrypt PHP extension. A...

php-dev Solved
PA
asked 1 month ago by Patrick Reck
0 votes
1 ans
3 views
What's the difference between isset() and array_key_exists()?

How do the following two function calls compare: isset($a['key']) array_key_exists('key', $a)

php-dev Solved
ZA
asked 1 month ago by Zacky112
0 votes
1 ans
3 views
PHP Constants Containing Arrays?

This failed: define('DEFAULT_ROLES', array('guy', 'development team')); Apparently, constants can't hold arrays. What is...

php-dev Solved
NI
asked 1 month ago by Nick Heiner
0 votes
1 ans
3 views
No Application Encryption Key Has Been Specified

I'm trying to use the `Artisan` command like this: php artisan serve It displays: > Laravel development server started: <http://127.0.0.1...

general-dev Solved
CA
asked 1 month ago by Carlos F
0 votes
1 ans
3 views
How to secure database passwords in PHP?

When a PHP application makes a database connection it of course generally needs to pass a login and password. If I'm using a single, minimum-permission logi...

database Solved
US
asked 1 month ago by user18359
0 votes
1 ans
3 views
Saving image from PHP URL

I need to save an image from a PHP URL to my PC. Let's say I have a page, `http://example.com/image.php`, holding a single "flower" image, nothin...

php-dev Solved
RI
asked 1 month ago by riad
0 votes
1 ans
3 views
When do I use the PHP constant "PHP_EOL"?

When is it a good idea to use [`PHP_EOL`][1]? I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues? [1]: https://...

php-dev Solved
CH
asked 1 month ago by Christian Oudard
0 votes
1 ans
3 views
What is the difference between bindParam and bindValue?

What is the difference between [`PDOStatement::bindParam()`][1] and [`PDOStatement::bindValue()`][2]? [1]: http://www.php.net/manual/en/pdostatement.bind...

general-dev Solved
KO
asked 1 month ago by koen
0 votes
1 ans
3 views
Displaying HTML with Blade shows the HTML code

I have a string returned to one of my views, like this: $text = '<p><strong>Lorem</strong> ipsum dolor <img src="images/tes...

general-dev Solved
LE
asked 1 month ago by lesssugar
0 votes
1 ans
3 views
Why doesn't this code simply print letters A to Z?

<?php for ($i = 'a'; $i <= 'z'; $i++) echo "$i\n"; This snippet gives the following output (newlines are re...

general-dev Solved
MI
asked 1 month ago by Milan Babuškov
0 votes
1 ans
3 views
How to set up file permissions for Laravel?

I'm using Apache Web Server that has the owner set to `_www:_www`. I never know what is the best practice with file permissions, for example when I create n...

php-dev Solved
RO
asked 1 month ago by Robo Robok
0 votes
1 ans
3 views
Creating default object from empty value in PHP?

I see this error only after upgrading my PHP environment to PHP 5.4 and beyond. The error points to this line of code: Error: >Creating default object...

php-dev Solved
PA
asked 1 month ago by Paul
0 votes
1 ans
3 views
Receive JSON POST with PHP

I’m trying to receive a JSON POST on a payment interface website, but I can’t decode it. When I print : echo $_POST; I get: Array The p...

php-dev Solved
PA
asked 1 month ago by Pablo Ramirez
0 votes
1 ans
3 views
What does PHP keyword 'var' do?

This is probably a very trivial question, but I haven't been able to find the answer neither through web search engines, nor on php.net. Please just direct...

php-dev Solved
JO
asked 1 month ago by joelpet
0 votes
1 ans
3 views
Can I try/catch a warning?

I need to catch some warnings being thrown from some php native functions and then handle them. Specifically: array dns_get_record ( string $hostname...

general-dev Solved
US
asked 1 month ago by user121196