Jump to content

Start using PHP

- - - - -

  • Please log in to reply
20 replies to this topic

#1
An Alien

An Alien

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 260 posts
Total noob here trying to learn PHP. I installed XAMPP for windows following that link. And I installed it. I pulled up the control panel and I had no idea what anything was. So I just stopped Mysql from the CP and exited. Can someone tell me how can I start using php on my comp?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
In the xampp directory, you will find a directory named htdocs. in that directory, or even better, in subdirectories to it, you place your .php files.
then you try them by browsing to http://localhost/sub...tory/myfile.php or whatever you name your directories or files...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
An Alien

An Alien

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 260 posts
thanks, I understand now.

#4
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Here is what you should do:
Open the control panel,
Start Apache,
Start MySQL (if you want to use databases),
Find your htdocs folder and clear it out,
Put all your PHP files in there (I recommend getting Notepad++ for writing PHP),
You can access your server from the same computer on "http://localhost/" you can also use PHPMyAdmin (A handy GUI tool for creating/managing/deleting MySQL databases, accounts and tables) at "http://localhost/phpmyadmin/".

Enjoy PHP!!
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#5
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
I totally disagree on "clearing out your htdocs"!! There are settings you can do from these files which is good for a beginner. it's a lot better to create your own subdirectory!
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#6
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Note that I am totally agree with Orjan, i.e. to use your own subdirectory instead of clearing out the default htdocs content. However that step actually is not dangerous. Yes, you would loose some sample page/script, but i think it will be fun to do it in order to learn a bit the basics of how apache works (like which one it prefer, index.html, index.php, or index.htm? things like that). And since XAMPP makes the installation very very easy, you don't have to worry to much in case you do break something. Just uninstall everything and reinstall.

#7
gon1387

gon1387

    Newbie

  • Members
  • PipPip
  • 17 posts
Putting the HTDOCS files and folders somewhere you can retrieve it when you need it will be a better Idea, or you can learn creating your own virtual hosts. :) Anyway, that's too far from learning PHP, but it can be a good start creating your own vitual hosts so you can have a different folder to play with.

#8
gon1387

gon1387

    Newbie

  • Members
  • PipPip
  • 17 posts
About your question, i forgot.. put your php files in here "%XAMPP FOLDER LOCATION%"/htdocs the default ussually is "C:\xampp\htdocs" you'll find preinstalled files there you can just cut it the put it on a different folder if you like, then on the HTDOCS folder, create a file called "index.php" ,without the quotes of course. Then, open it using notepad, then type this code..


<?php //open tag that denote a php script will be executed


echo "HELLO WORLD";  // THIS WILL OUTPUT HELLO WORLD IN YOUR BROWSER


?> // ending tag to denote the php script had just been ended



then save :)

go to your web browser, then on the address box, type "http://localhost/" or "http://127.0.0.1/"

you should see

"HELLO WORLD"

#9
An Alien

An Alien

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 260 posts
I have the xamp folder in my downloads. Can I/Should I move it to my C drive? Also, I have 3 folders in htdocs: forbidden, restricted, xampp and a bunch of image files

#10
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Your setup should be fine, feel free to clear your htdocs folder completely and write your scripts in there (i.e. htdocs/index.php) to get started.

Then you can browse it through http://localhost/index.php
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#11
An Alien

An Alien

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 260 posts
Do you mean delete the three folders, or just clean whats in them? Also, can I start writing php by just saving from notepad file.php into htdocs folder and then using my browser to that address? One more thing, if you guys know any good tutorials for very basics for starting php, link them to me plz.

#12
An Alien

An Alien

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 260 posts
Also, what's the relationship with php and mysql. And is xampp just a package for these different programming languages like java sdk is for java?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users