Jump to content

PHP Tutorial


Recommended Posts

  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hello everybody!We are currently trying to make the PHP part of the page better.We have taken a small break from writing the reference part (have made over 400 reference pages the last months), and we

A thing I certanly want to see is global variables handling, such as the GET variable. You know, the ones with which when you type "?VariableName=VariableValue" at the end of the URL to trigger specia

I don't know if it is an old idea or a new one, but is it possible to create a Try-it editor for PHP?Maybe eval() could be used for that, like eval($_POST['php_input']);Of cource with limitations

I think a fine addition to the PHP tutorial that would be good, without going too much spoonfeeding on the user, if it includes the regular expression functions.Now that theese functions are used in the Secure Mail script, such explanation is more requred then before. Not to mention regular expression functions are used in a lot of other scripts, such as the above mentioned BBCode for example.

Link to post
Share on other sites
  • 2 weeks later...
  • 1 month later...
Guest Jorn van Engelen

This PHP tutorial was very usefull.The only thing I couldn't find was how to put an [enter] in a file. :) I found the awnser of this question 2 weks ago. :) Just writefwrite($file,"\r\n");in your PHP file.I think this is very usefull for people who want to make a database without using mySQL.

Link to post
Share on other sites

It depends on the OS. DOS format is CRLF, Unix-based systems prefer LF only, and Mac-based systems prefer CR only.btw: LF = line feed = \nCR = carriage return = \rA Linux system seeing \r\n will sometimes show 2 newlines. But, for things like email headers, \r\n is required by the RFC to separate them, even though just \n is used in the email body.

Link to post
Share on other sites
  • 4 weeks later...

hi,PHP tutorial is nice ....adding to the above disc v can have something rel to ADO connectivity thru PHP - which is very useful 4 many appln proging ....then something covering PEAR packages ....shopping cart integrations ....last but not the least something rel to CMS tools ...

Link to post
Share on other sites

Specific applications like shopping carts and CMS programs typically don't have tutorials. You pretty much have to design it, break it down into features that you want and then figure out how to make each feature work individually.

Link to post
Share on other sites
  • 5 months later...
  • 6 months later...
  • 10 months later...

We should have something that deals with CMS with the PHP, I don't see anything that makes PHP work with SQL in there. Thats important for game designers, who plan to host their game online, or private servers for games like MapleStory, who need a database system for their website.

Link to post
Share on other sites

Something that needs to be fixed right away...On the file upload section (http://w3schools.com/php/php_file_upload.asp) the file_exists() function is called, but the value passed to it is the user's file name, so with the given setup, the script will always stop because the file that the user selected to upload does in fact exist.This can be fixed like so...

<?php$userfile = $_FILE['formfile']['name'];$name = basename($userfile);$dir = "some_upload_directory/";if (file_exists($dir.$name))   //code?>

On that note, a few other things I'd like to see in the file upload section are a reference of MIME types for common files (and the fact that $_FILE["file"]["type"] is a MIME type and not just a common extension - afaik this isn't mentioned anywhere).Also, I don't think it is mentioned ever that the "file" in $_FILE["file"] is the name of the file field in the form. I can see this being very confusing for a beginner. It should be changed to something to differentiate it from the $_FILE array.

Link to post
Share on other sites
...On that note, a few other things I'd like to see in the file upload section are a reference of MIME types for common files (and the fact that $_FILE["file"]["type"] is a MIME type and not just a common extension - afaik this isn't mentioned anywhere)....
Actually there is a MIME-types list on W3Schools. Just not in that tutorial :)See this list: http://www.w3schools.com/media/media_mimeref.asp (Media Tutorial)You're right about the "file" name of the file-input, indeed confusing. I would choose "userfile" or so.
Link to post
Share on other sites

On that list, I could not find application/x-httpd-php or application/x-httpd-phps ???*edit*I forgot to RTFM. "The reference below is a list of MIME types supported by Microsoft Internet Information Server version 5."M$ uses ASP don't they?

Link to post
Share on other sites

There can never really be a complete list of MIME types - for example, a new one could be invented for appml: application/appml+xml, and as long as the required agents understand, it is fine.IIS don't call their server a HTTPD though, so it may have a different MIME type for PHP documents.

Link to post
Share on other sites

The IIS that I'm looking at doesn't even have a mime type set up for PHP. That would make sense, because it's not sending the PHP files for download. There is an application mapping for PHP files, but not a mime type. If I wanted the server to send the files instead of execute them I could remove the application mapping and add a mime type.

Link to post
Share on other sites
  • 5 months later...

Not going to happen. It would be an enormous security threat to allow people to enter arbitrary server-side code for the server to execute. That goes for both PHP and ASP. There's no try-it editor for ASP code, either. Only client-side code. If you want to execute server-side code you need your own server (or space on someone else's). If you want to set up your own site to allow people to execute their own PHP code, fine, but don't expect your server to stay online very long.

Link to post
Share on other sites
  • 9 months later...

If the PHP tutorial is still being worked on, I'd like to see more object oriented concepts in php. Because the tutorial doesnt cover OOP, I've been reading "PHP Object-Oriented Solutions" by David Powers, which is a great book for a beginner, as well as getting help from forum members. It'd be nice to have reference of some of the basics so i dont have to flip through my book or go to php.net all the time.

Link to post
Share on other sites
  • 5 months later...
http://w3schools.com/php/php_looping.aspI'm extremely new to web design and programming so was hoping some one could clarify the below as it may be my understanding that is incorrect.In the tutorial
<html><body><?php $i=1;do  {  $i++;  echo "The number is " . $i . "<br />";  }while ($i<=5);?></body></html>

which would output:

The number is 2The number is 3The number is 4The number is 5The number is 6

But if my understanding of loops is correct this isn't strictly right, the i increment should be below the echo line:

<?php $i=1;do  {  echo "The number is " . $i . "<br />";   $i++;  }while ($i<=5);?>

which would return an output of:

The number is 1The number is 2The number is 3The number is 4The number is 5

If I'm mistaken I apologise, I'm alittle confused./Comf

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...