Jump to content

[SOLVED] PHP virgin :o


Drowzor

Recommended Posts

Hello all

 

I'm about as new to PHP as I am to this very forum. I've dealt with HTML and CSS just fine but the only PHP I know is from what I've gathered in passing conversations with others.

 

In short I'm looking for a good, open source PHP compiler. I'd like to add simple things to a website, such as under a contact me section, a way for the user to type a message into a text field, their name and contact details into other fields etc and a send button that will e-mail me with what they've done.

 

I'm sure the code for doing this can be found easily. It's more I need someone to teach me how to fish rather than give me the PHP code. Essentially I'd love to know:

 

A good open source PHP compiler

Once I've done the code, do I simply save the files and upload them to my server? (it supports PHP, it's a free awardspace one)

Do I insert some kind of object code into the HTML page which refers back to the PHP file or does it reference it like HTML points to a CSS file?

 

Once I get past this little milestone I can begin adding all sorts of new tricks to my site.

 

Additionally much later I'd like to know how to make things using Flex, the flash open source thing so any advice there would be great but that's pretty much another story for another day.

Link to comment
Share on other sites

Firstly, you won't find anything in the realm of a 'php compiler' ... php is an interpreted (non-compiled) language. There are many available resources on the internet for learning PHP.

 

The best way to learn in my opinion is to start with some simple php scripts (the ole 'hello world' standby is a good one) and then reverse engineer those scripts to figure out how they work.

Link to comment
Share on other sites

Thanks for the info. That's how I plan to set out.

 

So I need a PHP interpreter instead of a compiler.

 

Mostly asking because in HTML and CSS you just bust out notepad and change the file extension. I'm guessing PHP has a little more to it?

Link to comment
Share on other sites

A good open source PHP compiler

As mentioned above PHP code is not compiled. Unlike Java is for Java Applets. To run PHP code you need install PHP itself. To do so go to php.net to download the PHP interpreter. However installing PHP on its own will only give you an unhelpful command line. To run your scripts in your webbrowser on your computer you can install what is known as the AMP stack, This consists of Apache a HTTP server. MySQL a popular database server and PHP itself. This allows you to run your PHP scripts from your computer in your browser by going to http://localhost.

 

You can either download the above and install them individually or you can use an "All in one package". The post popular being WAMP (for Windows only) or XAMPP (for Windows, Linux and Mac). These install and configure the stack for you. I use WAMP personally. To use your PHP scripts with WAMP you need to save them to C:/wamp/www. All scripts must end in .php. This file can contain PHP and HTML. PHP code will not be parsed in .html files. To run your scripts you go to http://localhost/

 

You can use any editor to create your PHP scripts. No special software is needed, only the AMP stack for running PHP on your computer.

 

Once I've done the code, do I simply save the files and upload them to my server? (it supports PHP, it's a free awardspace one)

Yes you just upload it to your website as you do with your HTML/CSS/images etc.

 

Do I insert some kind of object code into the HTML page which refers back to the PHP file or does it reference it like HTML points to a CSS file?

No not quite. Just rename your .html files to .php. Now you you just add your PHP code within PHP tags (<?php ?>). You cannot call PHP code as you can with Javascript. PHP only works when a request has been made to the server.

Link to comment
Share on other sites

That's excellent thanks a lot.

 

I noticed with PHP there are versions too. The server I am using has the versions 4.4.1 or 5.2.5

 

Is this going to be a problem if make all my stuff on PHP 5.3.0 or are 5.2.5 and 5.3.0 compatible excluding one or two more advanced functions?

 

 

Link to comment
Share on other sites

Drowzor,

 

You shouldn't have too many compatibility issues (if any) between the minor releases.  The most major compatibility issue that PHP saw in recent times was the split from the 4 branch and into the 5 branch.  Overall though I don't think there was too much fuss in the community.  We are due to repeat though as PHP6 is on the horizons.

Link to comment
Share on other sites

Alrighty, I installed WAMP server 2.0i without any problems. Do I create my first page index.php and put it in the www directory like I would do index.html on a regular server? Then I just open them in my browser to see if it's working?

 

I would have to "start wamp server" first from the start menu right?

 

Going to http://localhost/ shows me all my WAMP server admin stuff just fine but I don't see any way to run the script. I've got some simple hello world script in a Hello.php file in the www directory waiting.

Link to comment
Share on other sites

Hi, I may get slandered for this  :o but if its just for contact forms and whatnot there are some scripts online that can generate.

 

When I was only using html/css/javascript, as a time saver I used this

 

http://phpformgen.sourceforge.net/ to generate my forms.

 

or if its just an add/edit/delete set of records i use

 

http://www.turningturnip.co.uk/free-mysql-php-generator/

 

Now as people are wanting more custom features, I come here to learn from the experts.  ;)

 

edit: sorry didnt read yur post very well NVM!

 

Link to comment
Share on other sites

Firstly, you won't find anything in the realm of a 'php compiler' ... php is an interpreted (non-compiled) language.

 

There is no reason why you couldn't write a PHP compiler, which is why it has already bee done.

 

I was a little surprised when I read it didn't use a compiler, especially as the first link I found was:

 

http://www.phpcompiler.org/

 

Hi, I may get slandered for this  :o but if its just for contact forms and whatnot there are some scripts online that can generate.

 

When I was only using html/css/javascript, as a time saver I used this

 

http://phpformgen.sourceforge.net/ to generate my forms.

 

or if its just an add/edit/delete set of records i use

 

http://www.turningturnip.co.uk/free-mysql-php-generator/

 

Now as people are wanting more custom features, I come here to learn from the experts.  ;)

 

edit: sorry didnt read yur post very well nevermind!

 

No doubt those will be useful but I do intend to learn a bit of PHP too. Mostly for any work that comes my way :3

Link to comment
Share on other sites

Ah ha... I've got it working now. Needed to save over/remove&replace the existing index.php and call my new file index.php THEN go to local host. I made my first page index.php and pasted my whole website directory into the www folder and it works like a dream.

 

Thanks a lot PHP freaks!

Link to comment
Share on other sites

Okay.  Yes there have been projects that have taken the interpreted language we know as PHP and ported the syntax to a program that can generate php code.

 

However, if you visit http://php.net (the official site for php), no where will you find a 'compiler'.  So since the official maintainers of the language do not offer it as a 'compiled' language then in my opinion it is not a 'compiled' language.

 

Lets also take note the differences between a 'compiled language' and a 'language compiler' (of which PHP is neither).  A language compiler is often a third party application that auto generates a particular language's syntax to speed up the code writing process. A language compiler can also be an application that takes readable syntax and reduces it to assembly language.

 

A compiled language is often a language who's run-time syntax is in binary form, C#, C++ .... etc.

 

PHP (as it is offered by the official project maintainers) is an interpreted language. Meaning that PHP is a set of files that has the ability to parse other files that use a particular set of syntax (scripts).  The inherit sign of an interpreted language is that the syntax of the language cannot be executed alone, it requires an 'interpreter' to translate the readable syntax into assembly/machine language for the computer to understand it.

 

There is an official port of the PHP core called PHP CLI (command line interface) that allows PHP syntax execution outside of the dependencies of a typical execution environment (a web server like Apache). Even so, it is still interpreted because the CLI core is interpreting the syntax into assembly or machine language.

 

Oh, but wait Ryan ... What about the Zend Encoder ... that makes PHP compiled right? Wrong. The Zend encoder does encrypt and encode the syntax however it does not 'compile' the syntax into assembly or machine language.  Why? Because you still need the Zend Encoder on the server in order to interpret the 'encoded' scripts.  The Zend Encoder is more for code security and optimization ... it isn't a 'compiler'.

 

In closing, even though there may be programs that 'auto -generate' PHP syntax or encode PHP syntax PHP is and always has been an interpreted language.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.