Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

How popular is PHP? And a real question...

General discussions related to php

Moderators: macek, egami, gesf

How popular is PHP? And a real question...

Postby gcm2 » Tue Apr 22, 2003 2:24 pm

I'm new to php/mySQL, and getting better at using it. It is so like Java (which I've been working with off and on for a year), that it's coming quite easily except for certain syntax differences. You know, classes & methods and functions and such. I have been concentrating on learning JSP (on Tomcat I downloaded).

Just curious as to how prevalent PHP is being used as a server-side or client-side scripting language.

Also - when reading in data (like from a database) and populating an HTML table, is it better to echo a bunch of html and php stuff, or drop out of a php block and do "pure" html with php snippets embedded?

Examples:

php block

<?php
while ($row = mysql_fetch_assoc($result)) {
echo "<tr><td>";
echo $row["firstname"];
echo "</td><td>";
echo $row["lastname"];
... and so on

drop out to html block

<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td><?php echo $row["firstname"]; ?>
</td>
<td><?php echo $row["lastname"]; ?>
</td>
... and so on


Thanks. :)
gcm2
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Apr 19, 2003 6:33 pm
Location: Ft Worth, TX

Postby liquedus » Tue Apr 22, 2003 5:16 pm

like java? 8O wow..... anyways since php is done server side and only html is sent to client, i guess it would depend on which one generates the file faster.
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Postby gcm2 » Tue Apr 22, 2003 6:51 pm

Yeah, you're right about Java... It IS different. I just mean that functions and classes (object-oriented stuff) looks very similar. It's not like looking at a foreign language since I used to be a C programmer anyway. Oh heck - I just mean that I'm picking it up quickly due to C and Java - or something like that... :)
gcm2
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Apr 19, 2003 6:33 pm
Location: Ft Worth, TX

Postby pootergeist » Wed Apr 23, 2003 3:25 am

it is slightly faster to drop out from php and hardcode the html - though using single quoted concatenated strings on your first example would also increase the speed (the php parser doesn't interpret single quoted strings so echo 'text $var text' would result in 'text $var text' whereas "text $var text" would give "text value text"

echo '<tr><td>' .$row["firstname"]. '</td><td>' .$row["lastname"];

as to PHP usage globally - it is the #1 module used on Apache server which is obviously the #1 server (3.1 million servers run PHP - http://www.securityspace.com/s_survey/d ... emods.html ) - even !yahoo (the worlds biggest site) has recently swapped from its proprietary !y1 and !y2 languages to begin using PHP as its main language.
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Re: How popular is PHP? And a real question...

Postby Redcircle » Tue Apr 29, 2003 2:43 am

gcm2 wrote:Also - when reading in data (like from a database) and populating an HTML table, is it better to echo a bunch of html and php stuff, or drop out of a php block and do "pure" html with php snippets embedded?

Examples:

php block

<?php
while ($row = mysql_fetch_assoc($result)) {
echo "<tr><td>";
echo $row["firstname"];
echo "</td><td>";
echo $row["lastname"];
... and so on

drop out to html block

<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td><?php echo $row["firstname"]; ?>
</td>
<td><?php echo $row["lastname"]; ?>
</td>
... and so on


Thanks. :)


well using the bottom one would be faster. But it all depends on the programmer on which they prefer to use. Some consider it sloppy to use the bottom method. I prefer to use the single quote method that pootergeist suggested.

And for PHP popularity I tried JSP a few years ago and no servers hosted it well.. no cheap servers did anyways.. So I went with PHP. Now JSP is the new Enterprise Fad. Too bad I'm not programming for enterprises. It's amazing how far PHP has come in 3 years. I throught it was awesome when I stumbled on it now I don't know how I would live without it. heck I even have dreams about it.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby gcm2 » Tue Apr 29, 2003 9:29 am

Thanks for the responses. I have since changed all my code to single-quote. I'm still learning this stuff... example:

<?php
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td>' . $row["firstname"] . '</td>';
echo '<td>' . $row["lastname"] . '</td>';
echo '<td>' . $row["lastvisit"] . '</td>';
echo "</tr>";
}
?>

I'm still learning PHP, along with Java/JSP/Beans. I just hope this is all worth it, and the whole universe doesn't go to .NET or something...
gcm2
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Apr 19, 2003 6:33 pm
Location: Ft Worth, TX

Postby leon » Wed Apr 30, 2003 1:29 am

how is popular php ?

look http://www.hotscripts.com the number of php scripts
compared with perl ..

1 years ago php scripts on hotscripts were below 3000
and 2 years below 1000 .. now they surpassed at the speed of light perl scripts ..... which are stable around 3500/4500 scripts in the last 2 years (!)

Looking hotscripts perl popularity is not growing/stable while php popularity is growing really fastttt in last years...
User avatar
leon
New php-forum User
New php-forum User
 
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

Postby *JaH* » Wed Apr 30, 2003 7:10 pm

another way to echo a big pile of html code is like this:
Code: Select all
print <<<END
<html>
  <head>
    <title>My Template</title>
  </head>
  <body>
    $gBODY
  </body>
</html>
END;


but most programmers seperate the html from the phpscript, that way the designer doesn't need to be a php-expert :)
*JaH*
New php-forum User
New php-forum User
 
Posts: 80
Joined: Fri Jan 31, 2003 4:18 pm

Postby Godiwa » Wed May 07, 2003 1:07 pm

another thing is to simply do an INCLUDE drag in all the html you want and if you have any Vars you want printed out on the page for the users then use <%=$var%> good luck with it, use it often in my code especially for forms and such.

Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am

Re: How popular is PHP? And a real question...

Postby WiZARD » Thu May 08, 2003 1:42 am

Hi
info about poputarity PHP in internet you may see at http://www.php.net/usage.php
by the way Java it's very interesting solution for intranet not for internet, cause for Java need very perfomaced computer(Server)...
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.