Showing posts with label php. Show all posts
Showing posts with label php. Show all posts
In any language a variable is something you use to store data, normally you give a variable its name and use it by that name.

$my_var = 5;
echo $my_var;

There is this concept called dynamic variables in PHP where you can dynamically name variables for example if you needed 100 variables named var 1 to 100 you would have to write all those variables one after another and use them throughout your code.

With dynamic variables you can create the variable names dynamically in code for example in a for loop or from user input. Here is an example how you'd create 100 dynamic variables:

for($i = 0; $i < 100;$i++)
{
${"var" . ($i+1)} = $i;
}

echo $var1;
echo $var 40;

You'll have to wrap the $var with {} and concatenate with . to create dynamic variables.


I see a lot of developers running into this error while using Laravel 5

FatalErrorException in compiled.php line 6391: Class 'Illuminate\Html\HtmlServiceProvider' not found

Solution

First add this line to composer.json
"illuminate/html": "~5.0"

Then do a composer update wait for the composer update to finish,
Then open the config/app.php add the line below:

'Illuminate\Html\HtmlServiceProvider',

and this

'Form'      => 'Illuminate\Html\FormFacade',
'Html'      => 'Illuminate\Html\HtmlFacade',

 and be sure when you use Html in blade or wherever use it in lowercase Html not HTML