English 中文(简体)
Debug PHP and Control Flow?
原标题:

I am an autodidact so dont know much about conventional web development however, I have wrote a complete social networking website yet I dont know how to debug. My website has some problems and I need to learn debuggin things around/

First of all I need instructions how to install Xdebug on WAMP (since I use phpDesigner). I tried a lot using tutorials on the web everytime I get a new error. I also tried puting it in the /ext/ directory and activating it from the WAMP PHP Extensions menu. Doesnt Work!

So if anyone odf you out there uses PHPDesigner with Xdebug (not the package that comes along, rather install it on WAMP) please help me and I would really be grateful. BTW PHP version is 5.3.0

Next thing is this is how is the the control flow of my website :-

htaccess -> redirect everything to index.php if file doesn t exist.

index.php ->

include all libraries  (__autoload).
initialize classes.

Get the $_SERVER[ REQUEST_URI ] to get the $page.

If $page is found

Check if the user is logged in,
if yes then include view/$page.php
or else redirect to login.php page

If page is not found then
redirect to 404.php

Is this control flow good for debugging? because I really cant understand the real MVC concept so I created something like this.

最佳回答

There is a tutorial for installing XDebug for use with phpDesigner here.

MVC is an organizing principle (also called a "design pattern"). It can be helpful keeping logically similar parts of a project together, and encouraging clean interfaces between them, but—especially for low complexity projects—strict MVC modeling isn t always an improvement.

You ask:

Is this control flow good for debugging?

Debugging is to identify flaws in programs. Writing a program to be easy to debug is like intentionally driving a car off the left side of the road so you ll know where to direct an ambulance to find you. Granted—there are small things which can be done to greatly improve debugability. But the point is to architect any control structure so it naturally expresses the algorithm. By doing that, it is far more likely to avoid the need to debug. Anything you can do to write correctly functioning code is justifiable.

Your control flow is clear to me. I wouldn t have any qualms about working on it.

问题回答

Use xDebug.

Its very easy to install and use. and you can download xDebug from here http://www.xdebug.org/

step by step tutorial for setup xdebug with WAMP is available at sachithsays.blogspot.com/





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签