Forum Moderators: coopster

Message Too Old, No Replies

A lot of PHP Questions PART 2

         

karlo

7:30 am on Feb 28, 2005 (gmt 0)

10+ Year Member



Ok, here's another. After looking at many PHP codes, I will call it "PHP Shortcuts". Do you still know any other "PHP Shortcuts"?

Example, to "print" the visitor's IP address, I use

<html><head></head><body><?php print $_SERVER['REMOTE_ADDR'];?></body></html>
After seeing someone's codes, I saw an easy way
<?=$_SERVER['REMOTE_ADDR'];?>
So, you know any more of that?

And for MySQL, I know there are many ways to retrieve the results. But how? Can you really teach me on how to use MySQL in PHP? Especially in LOOPS. I'm planning to create my own CMS. Please help me again. For my first thread, thank you all for helping me. But in this new thread, please help me!

dcrombie

11:08 am on Feb 28, 2005 (gmt 0)



You're really going to have to read the manual [php.net].
Everything you need to know is very clearly explained there.

[edited by: ergophobe at 7:09 pm (utc) on Feb. 28, 2005]
[edit reason] language - TOS [/edit]

Nutter

11:46 am on Feb 28, 2005 (gmt 0)

10+ Year Member



You really need to start with something simple. A CMS can get very complicated, very fast. They also can open up your server to all kinds of problems if you aren't careful. But, if you're determined, several of the good CMS's are open source so you can download their code and look at it.

And before focusing on short cuts, work on getting the 'right' way down. For that 'trick' you listed, I never use it. The time it would save me typing '=' instead of 'echo', isn't worth the possible confusion later when looking at the code.

Nutter

11:59 am on Feb 28, 2005 (gmt 0)

10+ Year Member



Let me follow up my last post. What I did when I started with PHP was to download the code to a CMS and try to add things. Most CMS packages have the ability to do add-ins and they are typically fairly easy to write. I found it easier to learn by modifying what was already there. Now I feel that I could write a full blown CMS, but still find it easier to modify one for my needs. I'm working on a Mambo site right now that's going to be heavily modified, but still uses the Mambo back end.

Although it helped that PHP was not my first language. I was already fairly fluent in VB, ASP, VBScript, and JavaScript before trying PHP.

henry0

1:09 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I second Nutter on "="
It goes against the well-established practice concept of commenting your code

Which not only help you working one code chunk at a time but also allows for other coders to understand your reasoning

So be sure to segment your code in chunks that are meaningful and can be reused for other coding purposes; for example not only an authentication function can easily be called just by calling the function but its main advantage is that it can be used and reused in many other scripts.