开发者

How do I start off with programming in PHP?

The title may have sounded a little vague, but I did not know how to articulate the question.

I want to create a webpage that will contain links to other webpages. But, I want to make it a little modular and want to write all of the functions in one page开发者_如何学JAVA and access it from the php script(webpage) that contains the part about displaying contents.

In short, I want to create a php page exclusively for displaying contents, and another for running the background functions.

Also, I have a LAMP architecture, and I just have the index.html page to begin with. How do I make it redirect to a php page?


First of all you should start exploring HTML, then Javascript, then PHP, then AJAX. Take one by one, using books, using other script sources, usign stackoverflow.com to get answers.

I learned all those steps in that order just by reading other peaople sources, exploring and testing then on my own.

Basic HTML is pretty simple if you know how is works.

Learn what can you do with javascript, of course, if you need it.

Your best friend for php is php.net as it will always answer most of the questions

These days javascript frameworks like jQuery simply tells you step by step how to do what you need.


Assuming your LAMP stack is correctly configured, you just need to rename your index.html to index.php.

Then start reading the manual! (I know that sounds unhelpful, but that's where I started and it's the best way for me to learn).

http://www.php.net/manual/en/index.php


Simply rename your index.html to index.php and it should work.

  • tizag.com (excellent beginner tutorials)
  • php.net – Contains the PHP manual, user-contributed examples and other documentation related to PHP.
  • phpfreaks.com (tutorials)

I ran two PHP workshops in 091 labs and made very trimmed down example apps. Slides and code here: http://091labs.com/wiki/?id=introduction_to_php

Edit: There's an error in the slides for week 1 there, the zend_extension line on setting up xdebug should have a .dll after php_xdebug

I see you already have a project in mind. Programming is best learned with a project rather than focusing on learning by reading alone, so stick with that.


What you described is essentially the Model-View-Controller paradigm used by most web application frameworks. MVC is designed to separate business logic from presentation.

I can't really give you a more specific answer since your question is very vague, but the simplest, most stripped-down way to accomplish MVC is to have two php files, one accessible from the outside, which then includes another file in a protected directory.

So for example you can have a functions.php file and then in your index.php file

require_once('lib/functions.php');
//call functions defined in functions.php

Aside from that, I think you just need to read up a bit and experiment on your own.


If you are starting PHP from scratch and you have LAMP up and running I would advise making a MySQL table with a bunch of strings that represent links to other pages.

I would then attempt to write an index.php page that can access this table and loop through the table displaying the links.

This is probably the easiest non trivial example of using PHP. Remember your page will need to be called index.php not index.html. Place the file in the same folder as your index.html for now.

Good luck!


I would suggest checking out lynda.com It's worth the money and it is a very good introduction to PHP/MySql

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜