Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Going to Learn PHP. . .Any Tips?

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
I've been usign CF for about 4 years now. really comfortable with it. I can make it do pretty much anything I need it to.

I might have to learn PHP for a new job. Are there any tips or things to do that might make it easier, coming from CF?

Anything that any of you have done that helped you learn it better?

Thanks!

 
CF = nothing likc PHP or ASP or JSP or even JS (except for cfscript)

You'll take the basics with you like how a loop works, variables, conditions and so on.

as far as syntax and functionality. Forget everything you know about CF it'll cloud your mind. It looks just like js

CF:
<cfset myMsg = "hi">
<cfif myMsg neq "">
<cfoutput>#myMsg#, My name is Travis</cfoutput>
<cfelse>
Go away
</cfif>

javaScript:
myMsg = "hi";
if(myMsg != ""){
document.write(myMsg + ', my name is Travis.');
}else{
document.write('Go Away');
}

PHP:
$myMsg = "hi";
if($myMsg != ""){
echo($myMsg + ', my name is Travis.');
}else{
echo('Go Away');
}

best advice is to keep the programming basics in mind, buy a book and don't expect anything like CF.


Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Being that javascript is a bit more friendly, it might help to wander into javascript and learn that.

By knowing javascript I can tell exactly which lines in php I shouldn't touch but that doesn't stop me :)

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
the cool thing about CF is how nicely it fits into HTML

<cfset greeting = "hi, my name is travis">
<html>
<body>
<!--- in CF you can mix html with the CF like this
<cfoutput>#greeting#. What is your name?</cfoutput>
<!--- or just use cfoutput around the CF lik this
<cfoutput>#greeting#</cfoutput>. What is your name?
</body>
</html>

PHP isn't that easy.
<?php
$greeting = "hi, my name is travis";
?>
<html>
<body>
<?php
//to put the html on the page inside the php block you have to put it in the echo function
echo($greeting + '. What is your name?');;
?>
<!-- to output just the variable only then go back to the html you have to put it inside php block --!>
<?php echo($greeting); ?>. What is your name
</body>
</html>

you can not create variables unless you are inside a php block. In CF you can put a variable decloration anywhere your heart desires.

to connect to a db in CF you use cfquery. Give it a name and assign a Datasource. PHP has different functions to connect to different types of databases. You have to create the sql as a string

cf:
<cfquery name = "cfSample" datasource = "#dsn#">
Select * from table where name = '#form.name#'
</cfquery>

in php you have to create a sql string
$sqlString = "select * from table where name = '"+$name+"'";

then you have to use it in a function call... i don't know the functions off hand or the exact syntax. its something like this though.

mysql_connect(dblocation, sqlString);




Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
The only advantage php has is that its familiar, most languages look something like php..

One learning method for you might be to research cfscript... learn to code in cfscript and you should understand all those (),{} parenthese things.

CFSCRIPT can do many things, not everything but many things.

I like it but I hope the tag interface always stays on par with the script interface.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
cool, thanks guys,
I use cfscript quite a bit, I've looked at php before, I think the hardest part is going to be getting used to doing so much extra work for something that was so simple in CF. Connecting to databases in ASP/VB was never any fun.

Well, the owner of the company knows I know no PHP, and is willing to have me learn, since I already have a grasp of web scripting. There is still a chance that I can get a CF server up for the projects instead of PHP, but they're a hardcore anti-MS crowd there. They didn't know CF would run in anything but windows, so they decided against it... screwy huh?

 
Screwy and Stupid (not on your part).

Its kind of goofy that Microsoft is hated for doing so much, I can get programmers hating them, but really, can you imagine if OS market-share was anything like where browsers were years ago and where they're (rumored to be) heading back to.

The major thing with CF is that while its RADder (heh), it doesn't actually accomplish very much more and has a price tag.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
I KNOW that the price of the server would be paid for WAY before I learn PHP well enough justin dev time. I'm hear working with database connections in php and holy crap, we're so spoiled with some of CFs features.
I'm actually looking forward to learning php anyways. It will be around forever, and I hated asp/vbs. It's just tough to see how long it takes to do something when I know I could do it with half the code in CF in some cases.

 
Hate to break it to you but ASP/VBS is comprable to the amount of coding you'll need in PHP. ASP is a container that uses VB functions like len(myVar). the asp part is the stuff like request.form("myvar"). If you don't like VBS you can still use jscript like myVar.length()

if request.form("myvar") = "myValue" then
do some stuff
end if

if(request.form("myVar").value == "myValue"){
do some stuff
}

are both do able in ASP. you just have to set the language if it isn't VBS (the default). My jscript syntax may be a touch off i've never USED it but I know it IS possible.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
bombboy, thats what I'm saying, I know!

The more I dig into it php, the more I like coldfusion...If I had a printable quick reference to the functions and operators and stuff, that would be cool, ever see a good one? Can't find one.

also, an editor with the usefull features of cfstudio would be cool. autocomplete, function insight, choose as you type kind of stuff. would really help with the learning.

Kevin

 
my goodness, I never realized how much I like Coldfusion until now...

 
I don't care for PHP at all. I've helped some people with it, made some small security scripts and xml parsing but hate it. It's all open source and it seems like it was written by a bunch of band geeks with nothing better to do on a saturday night rather than people that know what they're doing. The only thing it has going for it is, it's cross platform and free. good luck

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Image manipulation... It kicks CF's but royally on image manipulation...

On the other hand, so do most gradeschoolers... Always thought mm could do leaps and bounds better..

I don't care what it can do with flash, flash is not great for plain images... its too bandwidth heavy.

Sure "everyone's got broadband" but servers still have to pay if they feed too much out so for a plain image of flat text or whatever, they don't want flash.

Or at least I don't...

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
PHP has some stuff built in that CF doesn't have but it's all possible with CF using custom tags and componants. in fact it's easier to expand on CF because of the ability to quickly install a componant. Lets take alagad's image componant. It can resize, colorize, blur, sharpen, draw lines and shapes, add a watermark and a lot of other stuff. how do you use it? simply invoke the cfobject tag. Alagad did all the rest with java. if cf couldn't install componants it would never be done. what doesn't come in php doesn't happen until another hack adds it to the opensource code. If they know how to do it. You don't get componants, you get renagade versions of PHP running around.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
True,

I'm not and never have been a php programmer, I'm someone that saw a few features a few years ago (when I kinda got into php) and went oooooh, ahhhhhh, neato!

There's only one copy of CF as the source isn't available and the bad thing is that while yeah, mods for php are read over by the community and so would not have a hack (it'd be pretty hard to fool thousands of programmers looking for reason to say theirs is better than yours).. the privately distributed mods may contain hacks...

Custom tags run the same risk but a good bit less but CF is less... malicious by nature... php is raw, cf is sleek.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
MY GOD IT SUCKS! I HATE IT!

Especially trying to work with CRAP like zencart or oscommerce. Talk about overcoded convoluted messes!

What ever happened to keep it simple STUPID!?
Why do they insist on including and calling at least 10-20 php files every request?

It'a amazing how bloated that software is. it is hurting my brain!

I've GOT to talk this company into a CF server or at least a hosted server for some stuff...

Its an ISP with all FreeBSD... so they are all a bunch of perl freaks. don't get me started on perl for simple web sites. don't even.....






 
My tip for learning php, use the dreamweaver built in behaviors, they work fine for what they do, if they need a site so badly in some open source software they insist on using. Use the dreamweaver behaviors, tell them how much of a better job you could do in coldfusion (possibly install developer on a laptop or something and just show them!).
People who are all into open source, good for them, im happy on my 3 windows pcs. And my works Windows 2000 Server works fine.
All this antimicrosoft stuff does my nut!!!
Rant over!

CF Reference
The links of my knowledge
 
I never liked php. they have a built in function for everything. each database has seperate functions to connect to them, working with querries is very convoluded and messy. I wrote this big application which has to run almost 1000 lines of code every time a page loads. that runs faster than the old php page they were using and it only had a few lines of code.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Talk to them in dollars and sense (hehe). Even if you were a php ace you can code 20% (or more) faster in CF than in php (or asp). That makes CF cheaper on large projects even when you factor in the cost of the ap server.

Break down the numbers and show them how quickly CF will pay for itself.





BT
 
The cool thing is that its a small company of about 12 employees, and I already know 1/2 of them previous to employment.

The engineering team is meeting monday to discuss CF vs PHP.

NO ONE at the company knows either, except me (CF). Two of them are perl freaks, only because they don't know any other option. (perl does work well in the isp environment collecting user account stats and server states, but its crap for presenting the data to a web site. )

They knew that I did not know php, but have 4 years+ in CFML that alone should mean something. Some people get the 'I don't know what it is, so it must not be any good' syndrome.

The owner is only concerned that the job is done correctly.

I am to present to them a proposal to install a CF server for ecommerce, the ISP home page, and client sites that I build for local businesses, and future intranet applications. And a argument of CFM over PHP. I think today I got them to see what i can do with CFM and versus how long it would take to do in PHP (learning) and the quality of code that would be produced (learning a new language on a project generaly results in extremly poor code, even if it works.)

My freaking left eye is twitching now just thinking about it.. (the no sleep, too much caffiene probably doesn't help either...)

thanks for listening.!!!!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top