PHP programming

by 20 replies
24
#programming #php #programming
  • That's a very open ended question. The correct question is what do you consider to be features of good programming language vs what do you consider to be features of bad programming language?
    • [1] reply
    • Thanks, let me correct my question what are pros and cons of PHP as a programming language ?
  • Can you be little more clear with your question
  • Yes it is, one reason being that is tries to be both a object-oriented language and a functional language. Also function signatures are not consistent. For example you may have a string function where the "haystack" parameter is the first parameter and another string function where the "haystack" parameter is the last parameter.
  • One pro for PHP is the constant development of the language. New features are added and there is an upcoming version (5.7 or 7, what ever it will be) that will address performance issues and according to them will run at least 2 times as fast for current code.
  • I think PHP is beautiful. Especially when written OO style, but I keep hearing more and more about node.js which is a server side javascript language that is supposedly replacing PHP in the future.
    • [1] reply
  • hello,
    according to me php is just not that bad. using php you can solve any problem related to web site development. its a scripting language. there are many other languages which will help in web development but php is the simplest.
  • Here is the my code. I have created the code but everything is ok... but pagination is not working.


    Please Give a solution....

    Here is the code:


    <script type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    <?php

    $page_url = 'managepageuser.php';
    $display_per_page = constant("DISPLAYPERPAGE");

    if(isset($_GET['pages']) && $_GET['pages']!="1")
    {
    $pages = $_GET['pages'];
    $from_limit = ($pages-1) * $display_per_page;
    $to_limit = $from_limit + $display_per_page;
    }
    else
    {
    $pages = 1;
    $from_limit = 10;
    $to_limit = $from_limit + $display_per_page;
    }

    if($to_limit > $num_lists)
    {
    $to_limit = $num_lists;
    }


    if($num_lists > 0)
    {
    $total_pages = intval($num_lists / $display_per_page);
    if($total_pages!='0')
    {
    if(($num_lists % $display_per_page) !='0') { $total_pages = $total_pages +1; }
    }
    $prev = $pages - 1;
    $next = $pages + 1;
    $first = 1;
    $last = $total_pages;
    $pages_cnt = 1;
    if($total_pages > $pages_cnt)
    {
    $paging_txt .= "<a href='$page_url?pages=$first'>&laquo;&laquo; FIRST</a> | ";
    if($pages >1) { $paging_txt .= " <a href='$page_url?pages=$prev'>&laquo;PREVIOUS</a> | "; }
    $paging_txt .= "<select name=\"menu1\" onchange=\"MM_jumpMenu('parent',this,0)\">";

    while($pages_cnt <= $total_pages)
    {
    //$paging_txt .= " | <a href='$page_url?pages=$pages_cnt'>".$pages_cnt."</a>";
    $paging_txt .= "<option value='".$page_url."?pages=".$pages_cnt."'";
    if($pages_cnt == $_GET['pages']) { $paging_txt.= "selected"; }
    $paging_txt.= ">".$pages_cnt."</option>";
    $pages_cnt++;
    }

    $paging_txt .= "</select>";

    if($pages > 0 && $pages < $total_pages) { $paging_txt .= " | <a href='$page_url?pages=$next'>NEXT&raquo;</a>"; }
    if($pages !=$total_pages) { $paging_txt .= " | <a href='$page_url?pages=$last'>LAST &raquo;&raquo;</a>"; }
    }
    }
    ?>

    <?php
    if((isset($_GET['cmd'])) && ($_GET['cmd'] == "status")) {
    mysql_query("update $from_limittabledouser set driver_status='".$_GET['status']."' where driver_id='".$_GET['id']."'") or die(mysql_error());
    }
    if((isset($_GET['cmd'])) && ($_GET['cmd'] == "del")) {
    mysql_query("delete from $tabledouser where id='".$_GET['id']."'") or die(mysql_error());
    }

    /**** FETCH ALL DRIVER RECORDS ***/
    if($_SESSION['admintype'] == 'superadmin') {
    $sql_list = mysql_query("select * from $tabledouser order by user_name ASC") or die(mysql_error());
    $num_list = mysql_num_rows($sql_list);
    } else {
    $sql_list = mysql_query("select * from $tabledouser order by user_name ASC") or die(mysql_error());
    $num_list = mysql_num_rows($sql_list);
    }
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">

    <?php if(isset($_GET['success_msg'])) { ?>
    <tr>
    <td valign="top" align="center" class="greentxt"><?php echo $_GET['success_msg']; ?></td>
    </tr>
    <?php } ?>
    <?php if($num_list > 0) { ?>
    <tr>
    <td valign="top" align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="rowstbl display" rel="datatable" id="example">
    <thead>
    <tr>
    <th width="6%" align="center" nowrap="nowrap">&nbsp;</th>
    <th width="11%" align="center" nowrap="nowrap">ID </th>
    <th width="8%" align="center" nowrap="nowrap">User Name </th>
    <th width="8%" align="center" nowrap="nowrap">Full Name</th>
    <th width="28%" align="center" nowrap="nowrap">Email</th>
    <th width="17%" align="center" nowrap="nowrap">Mobile Number </th>
    <th width="8%" align="center" nowrap="nowrap">Time Login</th>
    <th width="10%" align="center" nowrap="nowrap">Edit</th>
    <th align="center">Delete</th>
    </tr>
    <tbody>
    <?php while($res_list = mysql_fetch_array($sql_list)) {
    $current_time = date("Y-m-d H:i:s");
    $last_current_time = date("Y-m-d H:i:s",mktime(date("H"),date("i")-1,date("s"),date("m"),date("d"),date("Y")));
    ?>
    <tr>
    <td align="center"><?php if((isset($_GET['id'])) && ($_GET['id'] == $res_list['id'])) { ?><img src="images/tick.png" /><?php } ?></td>
    <td align="center"><?php echo $res_list['id']; ?></td>
    <td align="center"><?php echo $res_list['user_name']; ?></td>
    <td align="center"><?php echo $res_list['full_name']; ?></td>
    <td align="center"><?php echo $res_list['email']; ?></td>
    <td align="center"><?php echo $res_list['cntrycode'].'-'.$res_list['mobile']; ?></td>
    <td align="center"><?php echo $res_list['create_at']; ?></td>
    <td align="center"><a href="javascript:confirmbox_edit(<?php echo $res_list['id']; ?>)"><img src="images/edit.png" width="29" height="29" border="0" /></a></td>
    <td align="center"><a href="javascript:confirmbox(<?php echo $res_list['id']; ?>)"><img src="images/delete.png" width="29" height="29" border="0" /></a></td>
    </tr>
    <?php } ?>
    </tbody>
    </table></td>
    </tr>
    <?php } else { ?>
    <tr>
    <td align="center" class="dtlboxbg tdmargin redtxt"><div align="center">NO RECORD FOUND</div></td>
    </tr>
    <?php } ?>
    </table>
  • There are mixed opinions about PHP. Is it a badly designed language?
    You can say that it is poorly maintained but to answer your above question, you will have to crack a debate here.

    Many people say that it creates ugly code and gives you tough time maintaining the code. But most of the time, it is not language's fault. It is developers fault which creates code bloats.
    • [ 1 ] Thanks
  • In my opinion, php is a badly designed programming language. The makers of PHP just wanted to solve a problem. PHP was something that happened and not a well thought out plan as Rasmus Lerdof, its creator says. Other languages, say like python was built for a purpose. Readability, easily deploy a site with little effort. Django, the most popular python framework has a tag line proving the same : "The web framework for perfectionists with deadlines.
    • [1] reply
    • 95% of my PHP code is OO. My PHP code looks as clean as Java or C#. If your PHP code looks bad, give up.
  • I dont think that php is badly designed language as most of the cms system are using php and its working quite well for even programers and end users too
  • Banned
    [DELETED]
  • [DELETED]
  • Any programming language is not bad, every language has their own pros and cons. php stands for hyper text preprocessor. it is open source programming language means php software's and code are freely available on the web and we can modify and enhance the code. no licence is required. php is most suited for web development.
    • [1] reply
    • PHP, like most languages, can be as good or bad as you make it.

      Lots of people turn their noses up at PHP because there is so much bad PHP code out there.

      Of course, most of those people that I have met don't write the greatest code themselves.

      Any good programmer can use most languages and end up with good clean code. Any mediocre programmer can use most languages and end up with something that is bloated and hard to maintain.

      I don't believe the language itself is badly designed. I just feel that being a relatively easy language to get started with (no need to learn about compilation, library linking, and other things that many languages need), lots of people new to programming use it with sub par results.

      I personally haven't encountered anything that was terribly hard to do with PHP excepting those things that PHP simply cannot do...
  • [DELETED]
  • I think you is fan ASP . I like PHP !
    • [1] reply
    • Sure, PHP has it's blemishes (like argument order inconsistencies mentioned by kdavies). But there's nothing so wrong with it that it's not a perfectly good language for web development.

      On the other hand, it has several major strengths, such as:

      * It's supported practically everywhere.
      * It's drop dead easy to get started using.
      * You can stick code inline in HTML code to add little dynamic bits anywhere you want.

      If it were a "bad" language, I'd think projects like WordPress would have moved to something else long ago. Are there other languages that are "better"? Depending on what aspects of the language are most important to you, I'm sure there are. But it's a perfectly acceptable alternative.
  • [DELETED]
  • PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.
  • Personal Home Page (PHP) is a very easy programming language. Since it is very flexible, most people may think at first that it is badly designed website development language. Don't listen to those. It is all about perception. Go and learn it at once!
  • Banned
    [DELETED]
  • Banned
    [DELETED]
  • Banned
    [DELETED]
  • [DELETED]

Next Topics on Trending Feed