doudu22272099831 2010-03-19 10:04
浏览 35

在PHP和Python Web开发中,我应该学习和使用什么才能成为专业人士?

I'll just show some code to show how I do web development in PHP.

<html>

<head>
<title>Example #3 TDavid's Very First PHP Script ever!</title>
</head>
<? print(Date("m/j/y")); 
require_once("somefile.php"); 
$mysql_db = "DATABASE NAME";
$mysql_user = "YOUR MYSQL USERNAME";
$mysql_pass = "YOUR MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $mysql_user, $mysql_pass);
mysql_select_db($mysql_db, $mysql_link);

$result = mysql_query("SELECT impressions from tds_counter where COUNT_ID='$cid'", $mysql_link);
if(mysql_num_rows($result)) {
   mysql_query("UPDATE tds_counter set impressions=impressions+1 where COUNT_ID='$cid'", $mysql_link);
   $row = mysql_fetch_row($result);
   if(!$inv) {
       print("$row[0]");
   }
}

?>

<body>
</body>
</html>

Thats it. I write every file like this. Recently, I learnt OOP and started using classes & objects in PHP.

I hear that there are many frameworks there for PHP. They say that one must use these libraries. But I feel they are just making things complicated.

Anyway, this is how I've been doing my web development. Now, I want to improve this. and make it professional. Also I want to move to Python. I searched SO archives and found everyone suggesting Django. But, can any one give me some idea about how web development in Python works?

user (client) request for page ---> webserver(->embedded PHP interpreter) ----> Server side(PHP) Script ---> MySQL Server.

Now, is it that instead of PHP interpreter there is python interpreter & instead of php script there is python script, which contains both HTML & python (embedded in some kind of python tags). Python script connects to database server and fetches some data which will be printed as HTML. or is it different in python world?

Is this Django thing like frameworks for PHP? Can't one code in python without using Django. Because, I never encountered any post without django

Please give me some kick start.

  • 写回答

5条回答 默认 最新

  • duanliaoyin3171 2010-03-19 10:07
    关注

    PHP was built for making web pages, so a lot of the infrastructure is already set up for you. Python was built more as a general-purpose scripting language so you need a bit of extra infrastructure to handle requests and produce web pages.

    There are multiple frameworks for Python. Django is the most popular but Pylons is another good one. Have a look at this list of Web Frameworks for Python:

    A web application may use a combination of a base HTTP application server, a storage mechanism such as a database, a template engine, a request dispatcher, an authentication module and an AJAX toolkit. These can be individual components or be provided together in a high-level framework.

    These are the most popular high-level frameworks. Many of them include components listed on the WebComponents page.

    • Django (1.1 Released 2009-07-29) a high-level Python Web framework that encourages rapid development and clean, pragmatic design

    • Grok (1.0 Released 2009-10-07) is built on the existing Zope 3 libraries, but aims to provide an easier learning curve and a more agile development experience. It does this by placing an emphasis on convention over configuration and DRY (Don't Repeat Yourself).

    • Pylons (0.9.7 Released 2009-02-23) a lightweight Web framework emphasizing flexibility and rapid development. It combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python Web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility but only if you need it. Out of the box, Pylons aims to make Web development fast, flexible and easy. Pylons is built on top of Paste (see below).

    • TurboGears (2.0 Released 2009-05-27) the rapid Web development megaframework you've been looking for. Combines CherryPy, Kid, SQLAlchemy and MochiKit. Create a database-driven, ready-to-extend application in minutes. All with designer friendly templates, easy AJAX on the browser side and on the server side, with an incredibly powerful and flexible Object Relational Mapper (ORM), and with code that is as natural as writing a function. After reviewing the website check out: QuickStart Manual

    • web2py (1.72.3 Released 2009-11-10) All in one package with no further dependencies. Development, deployment, debugging, testing, database administration and maintenance of applications can be done via the provided web interface. web2py has no configuration files, requires no installation, can be run off a USB drive. web2py uses Python for the Model, the Views and the Controllers, has a built-in ticketing system to manage errors, an internationalization engine, works with MySQL, PostgreSQL, SQLite , Oracle, MSSQL and the Google App Engine via an ORM abstraction layer. web2py includes libraries to handle HTML/XML, RSS, ATOM, CSV, RTF, JSON, AJAX, XMLRPC, WIKI markup. Production ready, capable of upload/download of very large files, and always backward compatible.

    • Zope (2.10.7 Released 2008-10-25, 2.11.2 Released 2008-25-10, Zope 3.4.0 Released 2009-01-29) Being the grandaddy of Python web frameworks, Zope has grown into a family of frameworks over the years. Zope 1 was released in 1999. Zope 2 is both a web framework and a general purpose application server, today it is primarily used by ContentManagementSystems

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘