| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Designers are strange :)
|
PHP Help...
I know there are some neat PHP programmers on here, so I bring you a problem. index.php PHP Code:
load.php PHP Code:
uri.php PHP Code:
Ok so what I'm trying t achieve is that when the user goes to index.php/helloworld, the helloworld controller will display. Thats exactly what the uri.php file does. I've checked that I am stripping the right bit down and I am passing it into the function...but the function won't handle it. The simple question is how can I pass a variable to a function and make it work? The longer question is, should I be coding PHP after 3 hours mountain biking?! lol. Any help appreciated If it works, it's valid.
|
|
|
|
|
|
#3 (permalink) |
|
Senior Member
Join Date: Oct 2006
Posts: 2,152
|
I'm not sure, but I think this: PHP Code:
Should be this? PHP Code:
Sorry i'm a newbie with the OOP stuff in PHP. Anyway, when bug fixing try echoing variables so you know you are doing it right. What error messages are you getting? |
|
|
|
#4 (permalink) |
|
Designers are strange :)
|
I did do that with the uri.php file. I echoed the $_SERVER['REQUEST_URI']; to see what it was getitng, and then I echoed the $uri['0'] and ['1'] and ['2'] to see what it echoed. I'll try taking the quotes out to see if it makes any difference. If it works, it's valid.
|
|
|
|
#5 (permalink) |
|
Designers are strange :)
|
OK guys. I've got it working. :P View it working!! It's not much visually at the moment :P But it works :P Now I have to build a class to use in the controller so I can load the view files. xD Thanks! If it works, it's valid.
|
|
|
|
#7 (permalink) |
|
Designers are strange :)
|
Yea it's my own made MVC system :p It would be easier to install CI, which is what I did initially. But then there were some drawbacks I had like when I used a .htaccess file to get rid of the index.php part, I couldn't show any images...but with this system I can. Plus I know how it all works and where''s the fun in downloading CI and installing it?! If it works, it's valid.
|
|
|
|
#9 (permalink) |
|
Designers are strange :)
|
The problem was in my controller. I hadn't put it into a class so I couldn't use the $load-> function. But then I needed to decalre $load again. The problem with the .htaccess file was that when I tried to include Index of /_img for example, it thought I was calling upon CI, and couldn't process it because _img isn't a controller. The same happened with the .css I guess the main reason behind doing this for myself rather than installing CI was that I really hadn't got a clue how CI worked. So I set out to make this framework to see how it's done. Now I have done it and have the basics working, I'm going to make it look better, and now have a function fail_gracefully() so that the application doesn't spit out dreaded PHP errors, but nice looking errors that report into an error log, so I can debug it later on. Obviously I won't turn off any PHP errors until I know it's all working and I change everything to use the fail_gracefully function. Plus my best mate has his portflio up and running, and he has a few PHP scripts, an upload script for one, and a blog script. But now I can put in my portfolio "PHP Framework" :P If it works, it's valid.
|
|
|
|
#10 (permalink) |
|
Everything is fine.
|
Hmmm, can't say that I've experienced the same problem as you with the images or CSS files not working and I use .htaccess too... Good for you though on wanting to discover the ins and outs of an MVC system, it will definitely help in the future to understand what goes on. |
|
|
|
#11 (permalink) |
|
Senior Member
Join Date: Oct 2006
Posts: 2,152
|
I've had the .htaccess problem you describe before, you need to ensure you are not rewriting urls for files that actually exist. This block of code should do it. Code:
|
|
![]() |