Announcement

Collapse
No announcement yet.

Java & PHP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java & PHP

    Quote below from this post:
    Originally posted by d_kendal
    the advantage to PHP (and the reason I'm learning it before I get into Javascript much) is that it's a server side language meaning that all the scripts you write run on the server then display as an HTML page for any browser eliminating the possibility of browser compatibility (which can definitely be a problem with java, the menu bar here is an example, a lot of people had problems with it, but as long as people keep their browsers updated it's generally not a problem) the other advantage to it is that your code is kept hidden since it only runs on the server and your page is output in HTML, where with javascript, your code is right there to anybody who decides to do a "View source". ASP is the same idea, but I prefer to go with the open source stuff and from what I've seen and learned so far, I like PHP better anyway.
    Thanks for that info David. (I've broken this discussion off to create a new thread so I can ask more questions without going to far out on a tangent in the other thread.)

    I've been a little worried about Java b/c of the browser issues, but then I wonder whether that worry is misplaced because every site that I've looked at for ideas on how to implement my own site has extensive Java script! (And I've looked at a lot!) Plus, it seems that both ImageReady and Dreamweaver automatically put out Java scripts for such things as rollovers, etc. That allows me to just tweak the code that's created rather than have to start from scratch. I know enough about programming languages to figure out what's going on and copy syntax without having to actually learn a whole new language.

    So, can PHP code create rollover effects like Java? Can it do basically anything Java can - without the browser imcompatibility issues? I guess most importantly, can it be worked in "after the fact"? Meaning, if I design my website using Java now (the path of least resistance a the moment) and decide later that I would prefer it to be implemented with PHP, can I work that in or would it necessitate me starting from scratch with my web design?

    Sorry for all of these questions.

    Jeanie
    Last edited by jeaniesa; 01-16-2003, 08:50 PM.

  • #2
    PHP and Javascript (really what we're talking about here) are really for different purposes. PHP is for dynamically making page content (pre-hypertext-processing). Javascript is for controlling your browser. Not that they can't overlap.

    For example, the page you're reading right now is generated by PHP. The navbar over on the left is Javascript, as are the little windows that popup when replying to a message so you can insert smilies or formatted text.
    Learn by teaching
    Take responsibility for learning

    Comment


    • #3
      Jeanie, Do you mean Java or JavaScript?

      Comment


      • #4
        Assuming that you mean JavaScript, Doug has given a pretty good summary.

        Server-side scripting (as with PHP or ASP) enables you to create dynamic content that is transparent to the browser client.

        Some stuff you can do in either JavaScript or PHP/ASP:

        For example, imagine you want your page to recognise (e.g. from a cookie) what the user's name is and say "Good morning" or "Good afternoon" based on the time.

        If you do this using a client-side script (e.g. client side JavaScript) you can easily get the page to read a cookie, find out that the visitor's name is Fred, check the current time, work out if it is morning or afternoon, and display "Good afternoon, Fred" on the screen - but if Fred views the source for the page he will be able to see all your JavaScript code.

        You can also do it using a server-side script (e.g. server-side PHP or ASP) - the logic will be pretty much the same BUT the processing is all done on the server BEFORE the page is sent to the client browser. So the screen will say "Good afternoon, Fred" AND if Fred views the source all he'll see is standard HTML saying "Good afternoon, Fred" as if you'd manually hard-coded it in that way in an .html file.

        For some purposes, it doesn't really matter which option you go for - for others, you might want to keep your logic hidden from the browser for sound business reasons or just to preserve an air of mystique...

        Some other stuff you'd really want to use PHP/ASP for:

        For example (this is the big one) any time you want to query or update a database.

        Other stuff you'd want to use JavaScript (or something else like dynamic HTML) for:

        For example, rollover buttons, special layout and presentation effects.

        Also verifying fields on a form - if you do that server-side you have to have the completed form sent to you, process the verification on the server, and then return the page with errors flagged up so that the user can resubmit it, you can recheck it, as like as not you rereturn it with the remaining errors flagged up so that the user can reresubmit it... can be a lengthy process. If you do it client-side the form never actually gets submitted until the JavaScript running on the client machine has checked that the form's been filled in OK, so all you get is one actual submission of the form to the server.

        General

        It's a case of horses for courses. Many pages will include some client-side and some server-side scripting. Plus of course you can embed client-side scripting inside server-side scripting so that you dynamically decide on the server which bits of JavaScript you want to include in the page... but at that point I generally have to go and lie down in a darkened room for a while.

        As a side issue - client-side scripting has cross-browser compatability issues (although these aren't generally as bad as you think) but can be run from any server, while server-side scripting has server compatability issues - if you plan to script in PHP or ASP you need to make sure that your site is being hosted on a server that supports it. Some hosting companies will charge extra for packages that include support for server-side scripting.

        And now I think my darkened room awaits...

        Comment


        • #5
          Yes, I meant JavaScript. Sorry! Once upon a time long, long ago I knew (really, I did!) that Java and JavaScript were two different beasts. (Doug, feel free to edit the subject of the thread to reflect that.)

          Thanks so much for the overview Doug & (esp.) Leah. Seems like I knew all of this at one time, but conveniently forgot! (E.g., I knew that PHP was useful for querying databases and displaying the results.) Good thing I've got four days of vacation this weekend - I need to get rid of the clutter in my brain! (Leah, I'll keep the darkened room idea for when I return - that may be the best piece of advice yet! )

          Jeanie

          Comment


          • #6
            Excellent overview Leah, I hadn't heard or read about the forms issue with server side languages, so thanks for that tip.
            Jeanie - JavaScript and PHP or ASP are kind of hard to compare, since they both have they're own advantages and are very different types of languages. for rollovers as an example, there's no PHP or ASP scripts for that as far as I know, you're best to stick to Javascript or Flash (which is also excellent for rollovers) but for things like dynamic content, the server side languages are far better.
            OOps, I confused the matter in my original post when I said java and meant javascript, sorry, I went back and edited it. oh, and it's best to do research and decide which one you want to use before doing a lot of work on a site as it can be a lot of pain to change over. using PHP / ASP can be a big advantage for site management since you can set it up so that you can make changes to the look of the entire site without painfully going through each html page because of the fact that it's dynamic content. sorry if I'm not making sense, my brain is tired, too much reading, thinking, and getting confused about coding, I'm going to sleep now!!

            - David

            Comment


            • #7
              Thanks for starting this thread...

              For a variety of reasons, I haven't been doing any photo work for a while and most recently, I've been boning up on HTML, Javascript etc to develop a web site for my son's business and I was wishing for a "RetouchPro" sort of forum where I could ask my newbie HTML questions.

              How great it is to find among my old friends people who are going down the same path.

              BTW - I'm putting my PhotoShop learning to good use in developing graphics for the site.

              Thanks again for the discussion,

              Take care, Margaret

              Comment


              • #8
                For David and all interested in PHP. I don't know if you have this site, but I came across it on my wanderings:

                http://www.hotscripts.com/Detailed/3718.html
                It supposedly answers questions you haven't even thought of yet. Hope it helps someone.
                Debbie

                Comment


                • #9
                  Thanks for the link Debbie, I hadn't found the site, even though I have looked around HotScripts quite a bit (that's where I found an excellent tutorial on loading PHP, MySQL and Apache on your own computer to act like a server to test out and develop a website before you actually have some real webserver space). looks like a good place to find answers to questions I have since I'm learning the language.

                  - David

                  Comment

                  Related Topics

                  Collapse

                  • Doug Nelson
                    Learning Javascript
                    by Doug Nelson
                    I'd like to see a discussion of the best way for a non-programmer to learn Javascript. I've seen the "for Dummies" type books, and I've seen the "read existing scripts and edit them to see what that does" advice, but they all presuppose some previous experience with some sort of...
                    01-23-2008, 04:57 PM
                  • 1STLITE
                    My web site - Tell me what you think
                    by 1STLITE
                    Well, after about three or four different layouts/menu styles, etc. I think I finally am satisfied with my web site. Other than adding content on these pages, and maybe adding a couple more pages, especially creating an info page (as it is I have my home page as the info also), I am pretty much done....
                    04-09-2006, 10:33 PM
                  • v.bampton
                    Any tuturials?
                    by v.bampton
                    I'm quite interested in photoshop's scripting capabilities, as actions don't have quite the flexibility I need. I don't have any programming experience, although I have gathered from another board that VBScript is what I need to use for what I have in mind (can't move/delete files using java? correct?)....
                    12-10-2004, 02:39 PM
                  • nebgranny
                    Firefox
                    by nebgranny
                    Awhile back when we were having problems with spyware someone here suggested Firefox. I am thinking of using it but have some questions first.

                    If Idownload it does it take over for IE ? Meaning will I still have that browser on my computer as well after I put Firefox on ? If both are...
                    05-21-2005, 09:14 AM
                  • copperman
                    Feedback please
                    by copperman
                    I have put together a draft of a site I created for photo restoration. I would like your feedback. Thanks.

                    http://photomajik.homestead.com

                    Thanks again. I learn new things here everyday.
                    12-30-2003, 03:55 PM
                  Working...
                  X