So I'm interested in starting PHP. I want a base index.php with references on how to link to a header.php file ans so on. I also want to know the markup for a linked PHP file. Does it need a whole head and body tag, or does it just need the div element with <?php> or whatever it is.
@nlfatkid I knew that WordPress worked on PHP, but I wanted to understand PHP so I could start, hence, why I'm asking. I could Google it, but I understand better when people on the forums tell me. Sometimes not, but most of the time.
I gotchya... I'm still kinda figuring out PHP myself... I don't have a good grasp on it either. It feels a lot like high school algebra to me. "If, then" statements still don't always make sense to me and it seems like the verbage of PHP doesn't always make sense. The thing that helped me understand PHP the most was WP. Have you looked at how a theme works? The construction of it? PHP works pretty damn close to it. I've always understand that the WP codex is a copy cat version of PHP. I just went through a huge battle with a guy on StackExchange, all over semantics of a PHP "loop" and the WP "Loop".
I agree with @kgscott284 -- you'll be better off learning things yourself than when people give you ready-to-use code. If you want to learn a new language, learn to walk before you jog.
But right.
To link a header in your index.php file:
<?php include 'header.php'; ?>
The contents of header.php will simply be placed where you call the include, so no additional header/footer/etc. needed.
The main idea is you can pretty much use any standard .html page and save it as a .php, then the server will recognize it as such. You may then include files, using php code, either a include or require depending...or use php code (as in the example provided.)
Hey Odd_E, There is no one right answer for this, the best thing to do is familiarize yourself with PHP before decided what style you'd like to code in
I do have a relevant tip though If you include a php file open it with <?php but don't close it, any trailing lines or spaces after ?> may cause errors, whereas leaving it open won't
These two YouTube channels are great for beginners right up to advanced http://www.youtube.com/user/phpacademy?ob=4 http://www.youtube.com/user/JREAMdesign/featured
Senff and Odd_E, I do agree w3schools is quite inaccurate--I have seen the w3fools before. However, in most cases, it provides a build-off platform-I learned the very basics there and then built off by googling other sites like this one.
I find it to be useful when I forget syntax or a function, but I do agree it is quite inaccurate.
@knittingfrenzy18 You're right, it can be helpful when it comes to the super bare basics. If I need something fairly simple (things like the basic syntax of a CASE statement in whatever language) and I google it, I often end up on W3Schools. So yea, I use it for quick reference every now and then, but I wouldn't recommend it to anyone as a starting course.
hmmm! What exactly do you need . I am not professional in php but i'm intermediate and i learn a lot. Php is great to work with. If you are a beginner i recommend you to buy a complete reference php book or try w3schools.com to learn php .
<?php>or whatever it is.Thank you.
http://php.net/manual/en/tutorial.php
should get you going on absolute for dummies level stuff.
@nlfatkid I knew that WordPress worked on PHP, but I wanted to understand PHP so I could start, hence, why I'm asking. I could Google it, but I understand better when people on the forums tell me. Sometimes not, but most of the time.
The thing that helped me understand PHP the most was WP. Have you looked at how a theme works?
The construction of it?
PHP works pretty damn close to it. I've always understand that the WP codex is a copy cat version of PHP. I just went through a huge battle with a guy on StackExchange, all over semantics of a PHP "loop" and the WP "Loop".
But right.
To link a header in your index.php file:
The contents of header.php will simply be placed where you call the include, so no additional header/footer/etc. needed.
More info: http://php.net/manual/en/function.include.php
Go get 'em!
The link i provided in fact answers one of your questions directly, it even provides a solid example noted in the code below.
The main idea is you can pretty much use any standard .html page and save it as a .php, then the server will recognize it as such. You may then include files, using php code, either a include or require depending...or use php code (as in the example provided.)
http://blog.themeforest.net/screencasts/diving-into-php-video-series/
There is no one right answer for this, the best thing to do is familiarize yourself with PHP before decided what style you'd like to code in
I do have a relevant tip though
If you include a php file open it with <?php but don't close it, any trailing lines or spaces after ?> may cause errors, whereas leaving it open won't
These two YouTube channels are great for beginners right up to advanced
http://www.youtube.com/user/phpacademy?ob=4
http://www.youtube.com/user/JREAMdesign/featured
Karl
I find it to be useful when I forget syntax or a function, but I do agree it is quite inaccurate.
http://webdevelopplus.com/php-tutorial-introduction
Since I was a beginner, when I want to know something I usually would design my problems first and then try to ask.