yakoup46 Posted April 13, 2009 Share Posted April 13, 2009 I have been messing around a lot with it and all I have created are some pointless, never going to be useful scripts. I have done mySql work which is very important but I was just curious if there is anything else that it is especially good for? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/ Share on other sites More sharing options...
premiso Posted April 13, 2009 Share Posted April 13, 2009 Making a dynamic website, such as this forum or a blog (wordpress) or an online text-game plus many other types of websites. PHP is good for pretty much any type of website you want to make that is dynamic. The best part of PHP is you do not have to pay for it to run as Apache is free, PHP is free and Linux is free. You do, however, have to pay for the space (harddrive space) and the bandwidth for the website. But as far as software is concerned the cost is very low, which is what makes PHP/Apache very attractive. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808628 Share on other sites More sharing options...
Daniel0 Posted April 13, 2009 Share Posted April 13, 2009 As an example of what it's good for, Facebook and Yahoo are using PHP just to name a few high profile websites. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808646 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 Really I didn't get the vibe that PHP had those capabilities. Like for example look at this JavaScript i wrote: <script type="text/javascript"> if (document.getElementById){ document.write('<style type="text/css">\n') document.write('.submenu{display: none;}\n') document.write('</style>\n') } function SwitchMenu(obj){ if(document.getElementById){ var el = document.getElementById(obj); var ar = document.getElementById("masterdiv").getElementsByTagName("span"); if(el.style.display != "block"){ for (var i=0; i<ar.length; i++){ if (ar.className=="submenu") ar.style.display = "none"; } el.style.display = "block"; }else{ el.style.display = "none"; } } } </script> This script basically make it so when you click on a heading it drops a menu and that menu can drop a menu etc. and when you click back on the heading it closes everything. I tried to replicate this on PHP with no luck. Can you help me? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808648 Share on other sites More sharing options...
Daniel0 Posted April 13, 2009 Share Posted April 13, 2009 PHP acts on the server side whereas Javascript acts on the client side. Neither of them can directly influence the other "side". Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808660 Share on other sites More sharing options...
premiso Posted April 13, 2009 Share Posted April 13, 2009 Javascript is Client side scripting. Meaning that it is controlled after the page has loaded. PHP is server side. They are two different items, apples and oranges. PHP is executed on the server side and thus cannot modify the webpage without a page reload. Where as Javascript can since that is what it is used for. Javascript, as such being on the client side, relies on the client allowing javascript. Where as PHP relies on the server and does not care what the client has. As such you really "cannot" replicate that, other than using CSS 2.0 to create the drop down instead of Javascript, but then again, you are using CSS, which relies somewhat on the client side given that each browser handles it a bit differently. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808661 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 Well Crap Can someone like give me an example of something that is "dynamic" with PHP? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808665 Share on other sites More sharing options...
NathanLedet Posted April 13, 2009 Share Posted April 13, 2009 That would be AJAX Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808678 Share on other sites More sharing options...
taquitosensei Posted April 13, 2009 Share Posted April 13, 2009 Here's an example of something dynamic if($a==1) { echo '$a equals 1'; } else { echo '$a doesn\'t equal 1' } At this point I'd suggest reading a book that shows how to develop a website using php Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808684 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 I have read books, but I just was hoping that PHP could do cool stuff like Javascript. ya konw? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808776 Share on other sites More sharing options...
NathanLedet Posted April 13, 2009 Share Posted April 13, 2009 no. Javascript does Javascript. If you don't like PHP - there's always ASP. good luck Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808783 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 PHP is by the easiest language i have ever learned. I just feel like it is a very limited language. I know I am mistaken because as someone said Yahoo and Google use it, so it must be good for something. Just not JavaScript like stuff. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808787 Share on other sites More sharing options...
Daniel0 Posted April 13, 2009 Share Posted April 13, 2009 [...] and Google use it [...] Nope, not Google. They use Python for their web pages. Anyway, I don't quite get your languages. PHP is good for making dynamic web pages. Virtually all web pages you see today will be dynamic in some way. Name your 10 (or 5) favorite web pages. All of them will be dynamic. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808789 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 So...sessions, being able to validate information without the user just circumventing the validation process, interacting with databases, and flatfile manipulation (to name a few) isn't cool enough for you? It's not really fair to compare php to javascript. They are 2 different languages, used in 2 different settings. If you're judging it based on how flashy you can make things, then sure, it's going to be at the bottom of your list. But that's because it's a server-side language. If you want to look at making things flashy, that's what clientside languages are for. You say that php is easy and limited, but I don't think you really understand the difference between a server environment and a client environment. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808790 Share on other sites More sharing options...
NathanLedet Posted April 13, 2009 Share Posted April 13, 2009 And someone also said it's like apples to oranges, which is completely true. Yes, Javascript does cool stuff. There is stuff like JQuery and other Javascript libraries that do some great things for your users experience - but you need a way to process and store that data - yes? That is what PHP is for. It's limited only to what you know. I've been dinking with PHP for years and still feel like an amateur. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808793 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 I did not mean to bash PHP. I would be lost without because i know no other way to interact with my databases. I use it very much, but just for Databases, really. But was is that flat line manipulation you spoke of that sounds interesting. Again I did not mean to lessen the value of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808798 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 flatfile* Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808800 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 file file_get_contents two of the "easier" functions, to get you started. You can also use functions like glob and readdir to find out what all files are in a directory in the first place. You can't do stuff like that with javascript. But again, that's because server-side and client-side are two different worlds. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808805 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 So what would be like a practical application of file_get_contents. Like in a personal webpage? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808815 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 well it's mostly useful for scraping webpages from other places. You would then use php to parse what you scraped (using regex or whatever). Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808820 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 oh. Is there anyway to make it search for certain words. Like all i have done so far is made it go to the file i did null for the flags part and started at -1 and went to 20 and it displayed the text. Can i make it search for a word start there and then go 20 characters more. Or can i have it search for a word and if its in the document yield TRUE or FALSE if it is not there, and if it is (TRUE) have it do another operation. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808824 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 yes. That's what regex is for. You would use for instance, preg_match or preg_match_all. You would make a pattern/rules for what you want to look for, and have it look for stuff matching the patterns/rules you specify. It can then extract what you are looking for or simply return true or false if it finds something matching the pattern, etc.. edit: so you would for example first use file_get_contents to get the file, then use regex functions to search/retrieve stuff. It really depends on what you are searching for as to how complex the pattern needs to be, or what function would be best. There are plenty of php functions that look for exact strings within other strings, etc... Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808828 Share on other sites More sharing options...
yakoup46 Posted April 13, 2009 Author Share Posted April 13, 2009 Sweet. So is Regex part of PHP like a set of operators or is it like a whole other section or what? Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808830 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 there are a couple of regex engines built into the php core, yes. pcre regex engine/functions is the one I suggest you use. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808833 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 Also, we have a forum dedicated to regex here. You can look at the stickies for more resources/info. Quote Link to comment https://forums.phpfreaks.com/topic/153863-i-am-new-to-php-what-exactly-is-it-good-for/#findComment-808835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.