FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Trying to start out!!!






Is redesigning my website in PHP a good thing?
yes
100%
 100%  [ 17 ]
no
0%
 0%  [ 0 ]
Total Votes : 17

IceCreamTruck
OK, here's the deal:

I have been a web programmer for many years, and although I'm slightly behind the times I figure it's better late than never to upgrade my website to PHP.

I was wondering if you guys would show me how you got your start, maybe some ups and downs of PHP, tips and tricks, etc. on programming in PHP.

The reason that I want to start php now is because I needed php5 (well, version 4 or higher) to be able to run my perl stats package inside php pages (yes, the older version of php on server two, frihost, wouldn't run perl scripts).

Now that everything I am doing on the web is possible in PHP I need YOUR HELP to start this project off. Come on guys!!! I know you can do it.

What I would like:
1. Free self help on PHP
2. Links to good starter PHP websites (tutorials, help, gettings started)
3. Links to good example sites
4. To pick your brain for PHP dos and don'ts
Manofgames
Good sites:
W3 Schools
Tizag
PHP manual

I started learning php from these sites, so I can vouch for their content Razz
The php manual is an invaluable reference, which I always visit.
A good option would be to actually download the manual http://www.php.net/download-docs.php

PHP Does and dont's:

NEVER write the php shorthand tag:
Code:

<?
//PHP code here
?>


ALWAYS write the php tags like so:
Code:

<?php
//PHP code here
?>


Not all servers support the shorthand tag, and it gets very annoying if your php code isn't interpreted, and all of your code is outputted as html.

Get a decent editor
If you don't already have it, get Notepad++. Its a great text editor, and a lot of coders I know swear by it Wink

Get a localhost!
You will not believe how much easier it is to test your scripts if you have a localhost on your pc.
Here's a tutorial I wrote for setting up a localhost:
http://frihost.broadkast.net/forums/viewtopic.php?f=8&p=90#p65

I'll post more tips as I think of them Smile
AftershockVibe
TIP 1:

Find a way to echo (print to browser) HTML and conform to it. Most people read code by it's shape, not by it's content and just because you're doing your actual coding in PHP echoing HTML doesn't mean you won't ever need to read it at the end.

If you indent HTML correctly when you're writing your PHP, you only need to do it once. Otherwise you need to do it every time you attempt to read the HTML page because your layout is mangled for some reason.

For example, I use the following style (apologies if tab spacing doesn't print correctly in PHPBB):
Code:

echo   '<body class="DocBody">' . '\n'
        . '    <div class="OuterHolder">' . '\n'
        . '        <div class="LeftPane">' . '\n'
        . '        </div>' . '\n'
        . '        <div class="RightPane">' . '\n'
        . '        </div>' . '\n'
        . '    </div>' . '\n'
        . '</body>' . '\n';



This makes your code readable both in the browser > view source and your original PHP script. Also, using "" for HTML quotes and '' for PHP means you don't have annoying escape characters everywhere. Just remember to escape apostrophes if you insert text directly.


TIP 2:

Use #include! Separating things into separate files makes it so much easier to ensure that each file is correct in itself. Then you can build your site up from smaller blocks which you know are correct.

For example, I'd use a header.php file which would include all the code I print at the top of every page. Things like starting PHP Sessions, enabling GZIP compression to save bandwidth and HTML <head> elements. (I do this and define a $title variable beforehand so that it picks it up and puts it in with the rest of the head).

This lets you build up and use the same template for every page. So when you create a new page you just create a new file which describes it's content, then change the filename in the template. So, if I have static content, this can just be plain text. Should it be a poll, then I can do all the images, database includes, etc contained nicely in a separate file which is only included when I want that particular page item.

e.g
Code:

$title = 'Poll Page';
include('common/header.php');

echo   '<body class="DocBody">' . '\n'
        . '    <div class="OuterHolder">' . '\n'
        . '        <div class="LeftPane">' . '\n';
                       include('content/menu.php');
echo   '        </div>' . '\n'
        . '        <div class="RightPane">' . '\n';
                       include('content/poll.php');
echo   '        </div>' . '\n'
        . '    </div>' . '\n'
        . '</body>' . '\n';



And, as Manofgames said, use Notepad++ if you're on Windows. It's awesome for HTML, CSS, PHP and probably a whole lot of other things as well. On Linux Kate and GEdit do this anyway.
Cool
imagefree
Code:
 #include('content/poll.php');


isnt it

Code:
 include('content/poll.php');

without the # sign? # is i think used in C and C++ etc
AftershockVibe
*cough* Fixed!

Wink
Agent ME
Actually, instead of using echo, if you don't have any code thrown in, you should do this - actually, if you want to show a variable, that's in this example too.
Code:
<?php
$lolvar = 2 + 4;
?>
<table>
  <tr>
    <td>Variable</td>
    <td>Value</td>
  </tr>
  <tr>
    <td>lolvar</td>
    <td><?=$lolvar?></td>
  </tr>
</table>
<?php
// more php code if you need it
?>

This way you don't need to echo all the lines of HTML.

(NOTE: I might have the HTML code for the table a bit off, or the shorthand for putting a variable inside unparsed code incorrect. Can someone else make sure its correct? I can't check it now.)
AOP Web Development
There's a lot of tutorials dude in the php scripts and if you wish to practice via localhost you can try to use xampp you can find it on apachefriends.org. This is a free and already configured server of APACHE,PHP 5,MYSQL 5. Just download a newier version.

Hope it helps.
woodenbrick
I found Zend's PHP 101 tutorials very easy to understand for a beginner and humorous (always helps).
http://devzone.zend.com/node/view/id/627
Like others have said, setup a localhost so you don't have to keep uploading the files to test them.[/url]
IceCreamTruck
I don't mind uploading files each time. It's just easier that way overall. Besides I have FOUR different domains that are the testing ground for the integrated web system that I have in mind.

I truely thank everyone who has contributed to this tread, and I want each of you to know that your input is valuable to me. You all gave me exactly what I was looking for, but it's going to take me some time to get through all of it!!!

LOL it's a lot of great information already. Ahem, please stand by... I will get back with you shortly as I read and re-read the thread and the linked sites in my quest for a greater understanding of PHP. Hey... I'm not far off because I can code Perl, and I know how to "#Include" my perl scripts know that Bondings has upgraded Server 2 to the impressive PHP version 5 (stuck on version 3 or something would NOT exec my perl scripts). That was the only down side to PHP: no stats (well, at least not the perl version I wrote myself for my purposes.

Now that PHP is fully upgraded (YEAH, BONDINGS RULES!!) I have no reason not to pursue a full PHP website with, of corse, my perl stats package that rules! Ask me and I might tailor you one. We are running one big advantage guys, and that's being live on the same web server.

Well, I'm off to re-read the tread. I have a lot of homework now!!!! thanks fellas
MRaftery
Manofgames wrote:
Good sites:
W3 Schools
Tizag
PHP manual

I started learning php from these sites, so I can vouch for their content Razz
The php manual is an invaluable reference, which I always visit.
A good option would be to actually download the manual http://www.php.net/download-docs.php

PHP Does and dont's:

NEVER write the php shorthand tag:
Code:

<?
//PHP code here
?>


ALWAYS write the php tags like so:
Code:

<?php
//PHP code here
?>


Not all servers support the shorthand tag, and it gets very annoying if your php code isn't interpreted, and all of your code is outputted as html.

Get a decent editor
If you don't already have it, get Notepad++. Its a great text editor, and a lot of coders I know swear by it Wink

Get a localhost!
You will not believe how much easier it is to test your scripts if you have a localhost on your pc.
Here's a tutorial I wrote for setting up a localhost:
http://frihost.broadkast.net/forums/viewtopic.php?f=8&p=90#p65

I'll post more tips as I think of them Smile


These were really useful..Thanks a lot!
roboguyspacedude
I pretty much got a small book from barnes and noble that didn't have much in it. I tried some scripts and got them to work, but the book just wasn't enough so I got The Dummies Guide to PHP/MYSQL, which I have found to be a very good reference book. I learned php over the course of a month by just doing test programs form books and making goals for myself, like i will build a login script by this weekend etc.
IceCreamTruck
I just wanted you to know that you guys have all helped me a great deal. I wish I had time to catch you up on what's been going on, but I really don't have time!!!

I'm just in from one appointment, and I'm back out the door on a completely new project now.

Everything is still going to plan, and going well but "Busy" durring the holidays doesn't really describe it for me.
mahirharoon
the editor i recommend is dev php
you should learn php from php.net
because it is 100% official
IceCreamTruck
Ok, I'm once again feeling the need to reply just to keep this post alive!!!! I want to hear more, and I don't want the post to die. ;-p It's a good one!!

Thanks again for the wealth of information that you guys have placed here, and know that I am pushing my way through all of it as quickly as I can.

I haven't hardly made a dent tho because it is so much. I keep pressing on however!
phpc0d3r
Here's a couple editors that I've found helpful:

E Text-editor: A copy of TextMate (a mac editor) on windows. It has code highlighting, and is easy to quickly edit files in. Plus it's only $30 to buy!
http://www.e-texteditor.com/

phpDesigner 2008: This one is a bit pricey, but it's a good investment for any serious PHP programmer (is that a oxymoron?)
http://www.mpsoftware.dk/

PSPad: This is an open source editor, that's free to download and use. It's mainly used for C++ programming, but has code highliting for PHP. (I forgot to mention it has interfaces for like 30 languages!)
http://pspad.com/
IceCreamTruck
NotePad++ is cool too!!
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.