Jump to content

Recommended Posts

Posted

Well i want to know a couple of things of PHP

 

Full form of PHP

 

Why is it much preffered for web sites than perl and htm

 

Can Turbo C and c++ can be used too ? :confused:

Posted

it is not much preferred to use pHp than html.

 

html is a markup language used to make a hypertext content page.

 

pHp is scripting language that works as a script on the server side to have interaction with the clients, for example, membership operation, search engine, etc, etc.

 

I don't know much about perl, but I guess pHp is easier to work with. Whereas for perl, it is a programming language??

 

I am pretty sure, you are completely new to this. You didnot even intimate what is your aim for making your website. You assimilate pHp, html, and C.

 

Practically, I never see people use C++ to make website, because it is a programming language, ie, you make programs, an individual sort of code runs by itself, not the script that run on the server.

Posted

PHP is not comparable to HTML as they have different uses. But it serves the same purpose as Perl does, I think the reason it is used alot more is because it is open source.

Posted

Perl is also open source :)

 

I would say that the main reason is that PHP was designed specifically for the purpose of serving dynamic content via webservers. While perl, admittedly, is a great language, programming for it can be a real pain sometimes, especially since it has to be run under CGI (most of the time).

 

As for the other question, it's perfectly possible to create "scripts" using C/C++. The advantage is that they will run extremely quickly, but the disadvantage is that they'll be quite hard to program under. Theoretically, you can create scripts under any language as long as that language has some standard i/o procedures. Python's a popular one at the moment.

Posted
I would say that the main reason is that PHP was designed specifically for the purpose of serving dynamic content via webservers. While perl, admittedly, is a great language, programming for it can be a real pain sometimes, especially since it has to be run under CGI (most of the time).

 

Yeah, with things like $_POST/_GET/_SESSION etc having all the session handling and grabbing of post and get data done for you, PHP is alot easier to work with for web content than Perl (which as far as i have seen requires you to parse/regex out the POST vars from the various environment variables set from the http headers (although there are probably some modules etc available that make this much easier). With the ease with which one can setup simple sessions or cookies and the ease with which they can be maintained in php, it no-wonder it is often used for web development. Also, by default in php there are so many functions that will simple do alot of your work for you and the php.net documentation is very easy to handle and using that and a few tutorials, php can be picked up in no-time (although obviously as with anything, theres a difference between doing something and doing it well), where others such as Perl can be somewhat harder to pick up (Perls semantics can be rather difficult if you havent done any programming before and the code can be rather hard to work with if you dont actively try and keep it neat (although this can be said of any language, it is especially true in this case in my opinion).

 

Links -

Wiki on PHP

More on PHP's Predefined Variables (_POST,_GET,_SESSION etc)

 

PS- Not saying this to you Dave as you already know it :P, just mentioning it as an additional comment/aside :D

 

PSS - Also I don't dislike Perl before anyone rants at me, I love it :D Just, right tool for the right job (sometimes that can be perl (it seems to have a much lower footprint than PHP (ie the memory usage because of the fact perl doesnt have nearly as much included by default (preferring modules) means it uses far less memory for the interpreter when running)) and has been perl in alot of high profile sites) :D

Posted

I think its a simple case of setting up your webserver to recognise certain filetypes and extensions are cgi (ie to execute them correctly and use the output rather than using the files contents).

 

For apache -

http://steinsoft.net/index.php?site=Programming/Code%20Snippets/Cpp/apache-c-script

A small tutorial on using C as a CGI language -

http://www.cs.tut.fi/~jkorpela/forms/cgic.html

 

Its all a case of handling http request info and sending back valid http responses (one of the reasons php is so easy, it does so much of this for you).

Posted

The thing I really love about PHP is how it has so many links to various libraries. If you take a look at the documentation, you can see that there are things from image manipulation and pdf generation all the way over to .NET libraries and database communications. We're spoilt for choice, really.

 

I'm also loving the new Zend Engine 2. It's making it a lot easier to program using objects - and it's also making it a lot quicker vs the normal procedural view. For instance, I've just about finished writing a rather complex backend which is extremely heavily OOP. As a part of that, I have things like object inheretance and abstract classes. Makes programming so much more interesting and elegant.

Posted

A better question would be why would one use PHP in preference to ASP. Those are the two most popular server-side application development platforms at the moment. PHP is open source from the Linux world (sometimes referred to as LAMP, for Linux + Apache + MySQL + PHP), and ASP is closed source from the Microsoft company.

 

There is a third alternative becoming popular right now called "AJAX", for asynchronous Javascript (not Java) and XML, which previously was not a technology one could use for server-side data access, but now it is (thanks to Microsoft, ironically). Expect to see a lot more open source development in this area over the next year or two -- it appears to be tipping.

 

I have no real experience in the PHP world but I have built a few applications for customers in ASP.NET, so I'd be happy to try and answer any questions regarding that area. I'm not a Microsoft evangelist but I do seem to have more or less hitched myself to their bandwagon in a lot of ways over the years (MCSE, etc).

Posted

Why C/C++ is also faster when being executed by the server??? Since here it is just a matter of another script type, which is not machine code after compilation.

 

Albert

Posted

Because Perl, PHP et al are interpreted scripts. Every time they're loaded, the parses has to go through it all line by line and translate to machine code. C/C++ programs are already compiled, so they can just be executed straight away.

Posted

PHP is a great language. It's preferred because it is so powerful and there are so many possibilties that it holds. I have seen people make MD5 crackers in PHP which is quite a feat I think. I love PHP. It is quite sexy.

Posted

CGI is a "protocol" of sorts; it's just a set of guidelines for things like webservers to pass data to programs and receive content from them.

 

Say you send a request to the webserver for test.cgi. In a perl script, the first line is usually something like #!/usr/bin/perl, which tells the webserver to execute: /usr/bin/perl test.cgi. Perl then parses the document, reads inputs from stdin from the webserver and outputs to stdout - the webserver then reads that output and serves it to the client.

 

With an executable, it's exactly the same process. The first line might be something completely different, but apache "knows" to execute the program and pass in a load of data to the program to stdin, and expect a load of information from stdout.

Posted
[...'] There is a third alternative becoming popular right now called "AJAX", for asynchronous Javascript (not Java) and XML, which previously was not a technology one could use for server-side data access, but now it is (thanks to Microsoft, ironically). [...]

AJAX is no alternative to PHP! AJAX only supplies a method to access server-side scripts without having to reload the page. It's just a derivative of Javascript and has been around for a looong time now, but it gained popularity after Google started to use it so extensively.

 

Because Perl, PHP et al are interpreted scripts. Every time they're loaded, the parses has to go through it all line by line and translate to machine code. C/C++ programs are already compiled, so they can just be executed straight away.

PHP code can also be pre-compiled ;) .

 

PHP is a great language. It's preferred because it is so powerful and there are so many possibilties that it holds. I have seen people make MD5 crackers in PHP which is quite a feat I think. I love PHP. It is quite sexy.

There are no "crackers" to MD5 because a MD5 hash doesn't include the original string. You can only brute force it and you can get strings that have the same hash but aren't identical to the original. You can MD5 hash a 5GB file and get a hash with the same length as when you hash a 2 character string.

Posted
AJAX is no alternative to PHP! AJAX only supplies a method to access server-side scripts without having to reload the page. It's just a derivative of Javascript and has been around for a looong time now' date=' but it gained popularity after Google started to use it so extensively.

[/quote']

 

Well I don't profess to be an expert, but many people seem to disagree with you. A lot of this comes down to semantics and finer points of which-computer-is-doing-what kinds of arguments, but the general consensus does seem to be that AJAX is an actual "application development"... something. (Environment? Platform? Concept? Approach? Pick one, hehe.) The point being that in terms of capabilities, it's in the ballpark at the very least, and at the very most, it's capable of doing anything you can do with PHP or ASP. (But again, whether that's true or not is the subject of heated debate at the moment, amongst far more intelligent and experienced people than I.)

 

The Wikipedia has a good write-up on it here:

http://en.wikipedia.org/wiki/AJAX

Posted
There are no "crackers" to MD5 because a MD5 hash doesn't include the original string. You can only brute force it and you can get strings that have the same hash but aren't identical to the original. You can MD5 hash a 5GB file and get a hash with the same length as when you hash a 2 character string.

 

Yes, I know. But if you say cracker, almost everyone will know what it means. Anyway, I was just using it as an example of how powerful PHP is. :P

Posted
AJAX is no alternative to PHP! AJAX only supplies a method to access server-side scripts without having to reload the page. It's just a derivative of Javascript and has been around for a looong time now, but it gained popularity after Google started to use it so extensively.

 

I beleive JavaScript is a form of AJAX and not the other way around. It has the ability to perform in any host environment so it could very well replace PHP.

Posted
PHP code can also be pre-compiled ;) .

 

Yes, but only if you're willing to pay. This is rather besides the point, though. I was simply trying to point out the difference between interpreted and compiled programs :)

Posted
Well I don't profess to be an expert' date=' but many people seem to disagree with you. A lot of this comes down to semantics and finer points of which-computer-is-doing-what kinds of arguments, but the general consensus does seem to be that AJAX is an actual "application development"... something. (Environment? Platform? Concept? Approach? Pick one, hehe.) The point being that in terms of capabilities, it's in the ballpark at the very least, and at the very most, it's capable of doing anything you can do with PHP or ASP. (But again, whether that's true or not is the subject of heated debate at the moment, amongst far more intelligent and experienced people than I.)

 

The Wikipedia has a good write-up on it here:

http://en.wikipedia.org/wiki/AJAX

AJAX runs on the client's computer and can't run on the server. It only delivers information TO the server and displays the response without having to reload the page. There is not more to it.

Maybe you should read the article yourself first? ;) It's explained in the paragraph "Compared to traditional web applications".

 

 

I beleive JavaScript is a form of AJAX and not the other way around. It has the ability to perform in any host environment so it could very well replace PHP.

AJAX is based on Javascript.

 

Yes, but only if you're willing to pay. This is rather besides the point, though. I was simply trying to point out the difference between interpreted and compiled programs :)

There are free alternatives.

Posted
CGI is a "protocol" of sorts; it's just a set of guidelines for things like webservers to pass data to programs and receive content from them.

 

Say you send a request to the webserver for test.cgi. In a perl script' date=' the first line is usually something like #!/usr/bin/perl, which tells the webserver to execute: /usr/bin/perl test.cgi. Perl then parses the document, reads inputs from stdin from the webserver and outputs to stdout - the webserver then reads that output and serves it to the client.

 

With an executable, it's exactly the same process. The first line might be something completely different, but apache "knows" to execute the program and pass in a load of data to the program to stdin, and expect a load of information from stdout.[/quote']

 

 

albertlee, I think dave's explanation already explained this. CGI itself isnt a language it is just a standard/protocol/interface that the webserver is setup to use that lets it know when and how to interact with executable files and to pass data back and forth to them to be processed for output.

 

Heres another link that might explain it some more - Wiki on CGI

 

 

AJAX is no alternative to PHP! AJAX only supplies a method to access server-side scripts without having to reload the page. It's just a derivative of Javascript and has been around for a looong time now' date=' but it gained popularity after Google started to use it so extensively.

[/quote']

 

I beleive JavaScript is a form of AJAX and not the other way around. It has the ability to perform in any host environment so it could very well replace PHP.

 

Agreed for the most part. The term AJAX refers to Javascript (ie Asynchronous Javascript and XML), however the way in which it works can easily be done with VBScript or any other client side browser scripting language. It simply involves using that client side browser scripting language to make requests to the server scripts (could well be PHP or Perl that simply serve up XML data rather than a static XML document (i would consider this much more likely otherwise it wouldnt make much sense)) (in the case of AJAX, the common request method being the use of the function XMLHttpRequest()) which in turn return only the data necessary (what was requested), which is then used by the client side browser script to alter the contents of the page to match the new data. This means that the whole page doesnt need to be refreshed, only a small amount of data needs to be transfered (ie the changes or additions), therefore saving bandwidth and offering a much more responsive and interactive site/application (ie doesnt require changing of pages as the browser script does it all behind the scenes).

 

JavaScript, despite what I would have thought does have a Server Side equivalent but from what I know that is nothing to do with AJAX primarily (although SSJS could be used to serve up the XML from the server side i suppose). I havent heard of it being used much but i have found mention of it.

 

SSJS

Posted
Agreed for the most part. The term AJAX refers to Javascript (ie Asynchronous Javascript and XML), however the way in which it works can easily be done with VBScript or any other client side browser scripting language.

Sure, but that is irrelevant. AJAX is no replacement for PHP or whatever, which is what this discussion initiated. And that you can use an idea and apply it on a different platform is obvious, it's done everywhere in every field of the economy.

 

It simply involves using that client side browser scripting language to make requests to the server scripts (could well be PHP or Perl that simply serve up XML data rather than a static XML document (i would consider this much more likely otherwise it wouldnt make much sense)) (in the case of AJAX, the common request method being the use of the function XMLHttpRequest()) which in turn return only the data necessary (what was requested), which is then used by the client side browser script to alter the contents of the page to match the new data. This means that the whole page doesnt need to be refreshed, only a small amount of data needs to be transfered (ie the changes or additions), therefore saving bandwidth and offering a much more responsive and interactive site/application (ie doesnt require changing of pages as the browser script does it all behind the scenes).

You might want to consider using some more paragraphs and punctuation to ease readability.

 

Anyways, you just restated what has already been said. And using acronyms and expressions which are obviously unknown to the other readers here has no point besides showing off, which is why I tried to keep it as simple as possible.

Posted

Icheb, i wasnt agreeing that AJAX could be used for Server Side scripting, I was simply agreeing in that Javascript is one tool used to do what AJAX does (which is what was stated in the following text). Sorry if this was ambiguous.

 

Also i posted my response but didn't see that there was another page to the topic. I didn't mean to reiterate what was being said. tje problem is once I've made the post I can't delete it. These posts (my original post and the replies to it) should be deleted but I obviously can't do that myself.

 

The only acronym i used was SSJS which i thought would have been simple enough considering i already mentioned Server Side JavaScript just before that point and it is also mentioned in the link i posted. It was not meant to try to show off in any way.

 

And yes i agree i should have spaced it out more.

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

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.