Results 1 to 12 of 12
Thread: Help to chose java or PHP
- 06-25-2011, 07:31 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Help to chose java or PHP
Hello Guy's
I know you have seen this question or somewhat of it many of times.
But I really need your help to decided.
I'm new to programming and stick in the middle of java and php.
Everything I have found relating to such questions which is best to learn, the same answer arises.
"Depends what you want to do... each has it's strength and weakness and it all comes down to what you want to do with the language, as one will be better then the other"
or something on those lines.
My questions is without starting a vs war, is what do they do better then each other. or even what do they do the other doesn't.
I want to create websites, and possible app's to support those sites. I know java would be suited for the later, but some say java is only used for large web applications. so why can't it be suited for small projects?
Anyway I hope you guy's understand what I'm trying to ask.
Regards
- 06-25-2011, 07:36 PM #2
PHP is used to dynamically generate content, generally in HTML, for a webpage output. For dynamic, on-the-fly-type web applications, PHP won't cut it. JavaScript (not Java) would be used for some small-scale apps, like a mini calculator or something. But Java should be used for any dynamic app that would be embedded in the website.
The two languages have severely different usages, so that question that keeps arising is a darn good one; it depends almost entirely on what you're doing in order to figure out what you want. If I were you (which I'm not, and I'm not sure the scope of your project), I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within. Though alternately, you could use AJAX (PHP handled by async JavaScript) to run a web application on a large scale.
- 06-25-2011, 07:44 PM #3
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Thank you for your reply, but it still leaves me in the dark. Without knowing what I can do, or the strength of a language I still can't decided to which I should learn.
Can you mix the two together as you stated
"I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within"
- 06-25-2011, 08:50 PM #4
Give us a detailed idea of what you want to do. What type of website are you trying to make? I would suggest PHP first because almost all websites use PHP now, and then Java afterwards. That's just a basic view point, you'll be able to get a lot more basic functionality out of PHP in the short run.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 06-26-2011, 01:53 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
My biggest reason for saying you should learn java first is because php can teach you some bad habits. For example, in php you can do this
The language is very weakly typed. If you learn php first you will be able to create a site quicker(probably), but you will (probably) have a harder time learning strongly typed languages like java later on.Java Code:$x = "hello"; $y = 10; $z = $x + $y;
- 06-26-2011, 02:39 AM #6
@Sunde, Sure there are some weaknesses like that, but it really depends on the individual. Honestly the best path is decided by what he's trying to accomplish in the website. If he's not planning on making anything super advanced that would require more than PHP then there really isn't a reason for him to start with Java. However if he plans to move into a really large development scheme with a lot of advanced functions then it might be in his best interest to skip over PHP and move straight into Java.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 06-26-2011, 02:44 AM #7
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Yes, exactly the point I meant to make. If he only ever plans on learning one language and doing just specific things such as web development, he may want to go with php. I just wanted to include some thing about php that could throw him off a little if he ever transitions to java or other strongly typed languages.
@op: I suggest you take a look at both, perhaps get an introductory text for each language and casually read through them to see which fits your needs better, and which will help you attain your goal more quickly.
- 06-26-2011, 10:41 AM #8
If you want more advice from us, I suggest giving us a broad overview of what you're trying to accomplish.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 06-26-2011, 11:48 PM #9
While I agree that PHP is "weakly"-typed (though I'd use the term flexibly, instead), this is not actually possible. Strings are concatenated using . while numbers are done with a + sign. And in fact, you can do this in Java also:
Yes. PHP is used for something entirely different than Java; Java does not generate contents of webpages, it runs inside its own application (from a JAR file on a computer) or applet (embedded in a website), independent of the content around it. PHP is used to generate the backend, the content that is visible to you.Java Code:String x = "hello"; int y = 10; String z = x + y; // Yes, this is defined as a string, but it still combines two variable types, something not possible in a strictly-typed language like C++.
Much more information on notable differences is available around the web.Last edited by Zack; 06-26-2011 at 11:51 PM.
- 06-26-2011, 11:57 PM #10
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
@zack, I'm aware php string concatenation is done with a period, I meant + as in addition. Adding a string and a number will return a number. Add
Java Code:echo $z;
- 06-27-2011, 02:08 AM #11
- 06-27-2011, 06:44 AM #12
Normally when designing a website you have a team. If you are the only one doing this then you might want to start with HTML/CSS/PHP so you can actually develop a website, and then learn Java so you can make applets for your website. You can essentially put all of the web development codes together on the same webpage.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
Similar Threads
-
Search function with multiple hits and ability to chose what hit is correct?
By pecca-ve in forum New To JavaReplies: 3Last Post: 01-10-2011, 01:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks