PHP Array
RobertJan Doeternietoe
12/04/2013 17:34:51Goedenmiddag,
Ik ben bezig met een config file, helaas krijg ik 1 ding niet voor elkaar..
Dit is de script..
Ik probeer om bij de "images" path automatisch de static url er voor te zetten met $config['urls']['static']
Maar zodra ik doe dan krijg ik niks te zien..
Weet iemand wat ik fout doe? Je zult je wel afvragen waarom ik dit zo doe, omdat ik nogal veel images moet laden in de html document, en dit zou het wat makkelijker/overzichterlijker maken.
Ik ben bezig met een config file, helaas krijg ik 1 ding niet voor elkaar..
Dit is de script..
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$config = array(
"database" => array(
"hostname" => "localhost",
"username" => "root",
"password" => "usbw",
"database" => "server1"
),
"urls" => array(
"baseurl" => "http://website.nl",
"staticurl" => "http://static.website.nl/"
),
"paths" => array(
"images" => $config['urls']['staticurl'] . "images"
)
);
?>
$config = array(
"database" => array(
"hostname" => "localhost",
"username" => "root",
"password" => "usbw",
"database" => "server1"
),
"urls" => array(
"baseurl" => "http://website.nl",
"staticurl" => "http://static.website.nl/"
),
"paths" => array(
"images" => $config['urls']['staticurl'] . "images"
)
);
?>
Ik probeer om bij de "images" path automatisch de static url er voor te zetten met $config['urls']['static']
Maar zodra ik doe dan krijg ik niks te zien..
Weet iemand wat ik fout doe? Je zult je wel afvragen waarom ik dit zo doe, omdat ik nogal veel images moet laden in de html document, en dit zou het wat makkelijker/overzichterlijker maken.
PHP hulp
04/05/2024 12:32:03- SanThe -
12/04/2013 17:42:58Je hebt blijkbaar je error_reporting niet aan staan.
Er volgt een Notice: Undefined variable: config ....
Je wilt een array vullen met een array dat je nog aan het vullen bent.
Gaat niet werken lijkt mij.
Er volgt een Notice: Undefined variable: config ....
Je wilt een array vullen met een array dat je nog aan het vullen bent.
Gaat niet werken lijkt mij.
Erwin H
12/04/2013 17:45:22gewoon opbreken in stukken en het werkt:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
$config = array(
"database" => array(
"hostname" => "localhost",
"username" => "root",
"password" => "usbw",
"database" => "server1"
),
"urls" => array(
"baseurl" => "http://website.nl",
"staticurl" => "http://static.website.nl/"
)
);
$config["paths"] = array(
"images" => $config['urls']['staticurl'] . "images"
);
?>
$config = array(
"database" => array(
"hostname" => "localhost",
"username" => "root",
"password" => "usbw",
"database" => "server1"
),
"urls" => array(
"baseurl" => "http://website.nl",
"staticurl" => "http://static.website.nl/"
)
);
$config["paths"] = array(
"images" => $config['urls']['staticurl'] . "images"
);
?>