Jump to content
xisto Community
Spectre

Php - The Basics Learn the basics of PHP

Recommended Posts

Wow, seems very complicated. Is there a powerful software that let's you create PHP easily. Something easy to use.

 

what's the difference between PHP and CGI?

189492[/snapback]


CGI is a Perl (Im am not shure) or Python script. I think its perl!

Share this post


Link to post
Share on other sites

This is getting slightly off topic. But anyway, Perl is a CGI; so is Python. PHP can be run as a CGI, but most people usually favor the module (for security and other reasons - but not all web servers support this). CGI stands for common gateway interface, and is basically a server-side program that the web server can interface with, allowing for certain scripts to be executed on the server.

 

Anyway, thanks for all your comments. Maybe I'll get around to writing up a second part some time. And HmmZ, feel free to expand on it.

Share this post


Link to post
Share on other sites

PHP started as a Perl module. Now it may be installed independently; as a apache mod.A few notes:1. Instead of using <? ?>, which is a shortcut (and may not work in some servers), use <?php ?>2. Try to improve your indentation. 3. There are major differences between the comparision operator "==" (equal) and "===" (identical).For example, "php" == 0 returns true, but "php" === 0 doesn't.

Share this post


Link to post
Share on other sites

thx for the tut, im just starting out so it was very helpful. however, is there a way to make is easier? like some sort of php software? there are like html software and html editing, so there may be a php thinga miggy

Share this post


Link to post
Share on other sites

Wow, this is really complicated stuff. This is a really great tutorial but I think its Aimed more at the users who know the really basic stuff about PHP. I'm not really sure, but I think theres more basic stuff to PHP than what is already stated in this section of the guide. Also, just really curious, but do you actually have to know HTML first to learn PHP?

Share this post


Link to post
Share on other sites

mendezgarcia, I'll assume that was directed at me.

 

PHP started as a Perl module. Now it may be installed independently; as a apache mod.

That was a long time ago - when PHP first came about. It moved to an executable CGI after that, and is now available in various forms, including an Apache module (although it is in no way limited to this).

 

1. Instead of using <? ?>, which is a shortcut (and may not work in some servers), use <?php ?>

I do always use <?php ?> in scripts. In the beginning of the tutorial, I noted that anything outside of the <? ?> tags will be ignored - but this isn't unique to PHP. There are numerous scripting engines (some more widely used than otehrs) that use <?(.*?) ?> to determine what should be processed and what shouldn't. It is true, however, that using <?php ?> is best practise and should always be compatible.

 

2. Try to improve your indentation.

Normally, indentation is up to 9 blank spaces, whether they are actually 9 consecutive instances of 0x20 or a single 0x9 (incrementing each level - or least, that's how I do it); IPB trims the character 0x09, and I -think- it trims more than a few consecutive spaces or character 0x20. As such, code in this post is not particularly well indented. That aside, it is only concept code - most of the code posted here would not actually work anyway (or would have very little value) in the form in which it currently exists (eg. '} else { statement; }' - obviously, not a real statement). Structure is not incredibly important in this particular tutorial (and the only reason it matters elsewhere is for ease of readibility, something which, for one reason or another, is not always wanted).

 

3. There are major differences between the comparision operator "==" (equal) and "===" (identical).

 

For example, "php" == 0 returns true, but "php" === 0 doesn't.


I already mentioned this in 'if...then..else'. There are not major differences - the former checks only the value, the latter both value and type (eg. $x == 4 would match a string value of '4'; $x === 4 would not). See: 'It is also possible to set explicit condition requirements by using an additional equals symbol...'. I didn't cover it in great detail, but it was mentioned.

Share this post


Link to post
Share on other sites

Just to answer to those of you who are looking for "php visual programs". There is NO such a thing. PHP is programming language and you can see its results only after execution (somtimes compilation). Anyway, to learn PHP you must learn the language itself, you cant "draw" it or anything like that, just simple coding. And you dont have to know HTML to write PHP code, but it's highly recommended, so you can implement what you create with PHP into the real world project.

Share this post


Link to post
Share on other sites

Wow, I found this tutorial amazing for a beginer like me. I just have bookmarked it because I think it will help me in the future. I?m trying to learn php and although I don?t have too much free time I hope to get it finally. Maybe some day I could make my own scripts without disturbing my friends constantly with code issues. :huh: Thanks a lot.

Share this post


Link to post
Share on other sites

That was a long time ago - when PHP first came about. It moved to an executable CGI after that, and is now available in various forms, including an Apache module (although it is in no way limited to this).

Yes, I was answering him: PHP started as a Perl module and now MAY be installed as an Apache module.
I didn't know IPB would mess the indentation :)

About the equal and identical operators, although they are apparently the same thing, they are very different. There was a security flaw in phpBB (security flaw number 6.57 x 10^6) that was fixed changing == to ===

Share this post


Link to post
Share on other sites

I already mentioned this in 'if...then..else'. There are not major differences - the former checks only the value, the latter both value and type (eg. $x == 4 would match a string value of '4'; $x === 4 would not). See: 'It is also possible to set explicit condition requirements by using an additional equals symbol...'. I didn't cover it in great detail, but it was mentioned.

192088[/snapback]

I thought I was fairly good with PHP, by no means an expert but knew enough to get by. I learnt something from the tutorial, I wasn't aware of '===' until now. Thanks! :)

 

Excellent tutorial Spectre, you obviously spent a lot of time putting it together, well done! I hope you decide to complete the "To be continued..." section soon.

 

P.S. While it is true you cannot just preview a PHP script in action in your browser like you can HTML, you can set up your own personal web server with PHP running and test scripts that way. That's what I do, you just need to remember to change the server parameters (if any) in the script, such as connection parameters for a mysql database, when you finally upload to an online server.

Share this post


Link to post
Share on other sites

P.S. While it is true you cannot just preview a PHP script in action in your browser like you can HTML, you can set up your own personal web server with PHP running and test scripts that way. That's what I do, you just need to remember to change the server parameters (if any) in the script, such as connection parameters for a mysql database, when you finally upload to an online server.

194381[/snapback]


Yes, use something like XAMPP

https://sourceforge.net/projects/xampp/

 

Another create a config file (which will be required every time).

For example:

 

define ("MYSQL_USER", "mendez");

and:

 

require 'config.php';

mysql_connect("localhost", MYSQL_USER, ...);

 

Easy... :)

Share this post


Link to post
Share on other sites

really nice attempt and should be praised. You should also mention some thing about sessions and cookies.thanksacumentech

Notice from wassie:
please dont quote such long posts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.