仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1455|回复: 19
打印 上一主题 下一主题

[学习教程] PHP网页设计一段php代码:备份、恢复sql数据库(支...

[复制链接]
透明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-4 00:18:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
掌握静态网页的制作技术是学习开发网站的先决条件,这一点就讲到这里,因为这篇文章不是教程文章,也就不对技术进行深入的刨析了。备份|恢复|数据|数据库   PHP代码:--------------------------------------------------------------------------------

<?php


require('includes/application_top.php');

if ($HTTP_GET_VARS['action']) {
switch ($HTTP_GET_VARS['action']) {
case 'forget':
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'DB_LAST_RESTORE'");
$messageStack->add_session(SUCCESS_LAST_RESTORE_CLEARED, 'success');
tep_redirect(tep_href_link(FILENAME_BACKUP));
break;
case 'backupnow':
tep_set_time_limit(0);
$schema = '# citespa, Open Source E-Commerce Solutions' . "\n" .
'# <a href="http://www.XXXXXX.com" target="_blank">http://www.XXXXXX.com</a>' . "\n" .
'#' . "\n" .
'# Database Backup For ' . STORE_NAME . "\n" .
'# Copyright (c) ' . date('Y') . ' ' . STORE_OWNER . "\n" .
'#' . "\n" .
'# Database: ' . DB_DATABASE . "\n" .
'# Database Server: ' . DB_SERVER . "\n" .
'#' . "\n" .
'# Backup Date: ' . date(PHP_DATE_TIME_FORMAT) . "\n\n";
$tables_query = tep_db_query('show tables');
while ($tables = tep_db_fetch_array($tables_query)) {
list(,$table) = each($tables);
$schema .= 'drop table if exists ' . $table . ';' . "\n" .
'create table ' . $table . ' (' . "\n";
$table_list = array();
$fields_query = tep_db_query("show fields from " . $table);
while ($fields = tep_db_fetch_array($fields_query)) {
$table_list[] = $fields['Field'];
$schema .= ' ' . $fields['Field'] . ' ' . $fields['Type'];
if (strlen($fields['Default']) > 0) $schema .= ' default '' . $fields['Default'] . ''';
if ($fields['Null'] != 'YES') $schema .= ' not null';
if (isset($fields['Extra'])) $schema .= ' ' . $fields['Extra'];
$schema .= ',' . "\n";
}
$schema = ereg_replace(",\n$", '', $schema);

// Add the keys
$index = array();
$keys_query = tep_db_query("show keys from " . $table);
while ($keys = tep_db_fetch_array($keys_query)) {
$kname = $keys['Key_name'];
if (!isset($index[$kname])) {
$index[$kname] = array('unique' => !$keys['Non_unique'],
'columns' => array());
}
$index[$kname]['columns'][] = $keys['Column_name'];
}
while (list($kname, $info) = each($index)) {
$schema .= ',' . "\n";
$columns = implode($info['columns'], ', ');
if ($kname == 'PRIMARY') {
$schema .= ' PRIMARY KEY (' . $columns . ')';
} elseif ($info['unique']) {
$schema .= ' UNIQUE ' . $kname . ' (' . $columns . ')';
} else {
$schema .= ' KEY ' . $kname . ' (' . $columns . ')';
}
}
$schema .= "\n" . ');' . "\n\n";

// Dump the data
$rows_query = tep_db_query("select " . implode(',', $table_list) . " from " . $table);
while ($rows = tep_db_fetch_array($rows_query)) {
$schema_insert = 'insert into ' . $table . ' (' . implode(', ', $table_list) . ') values (';
reset($table_list);
while (list(,$i) = each($table_list)) {
if (!isset($rows[$i])) {
$schema_insert .= 'NULL, ';
} elseif ($rows[$i] != '') {
$row = addslashes($rows[$i]);
$row = ereg_replace("\n#", "\n".'#', $row);
$schema_insert .= ''' . $row . '', ';
} else {
$schema_insert .= ''', ';
}
}
$schema_insert = ereg_replace(', $', '', $schema_insert) . ');' . "\n";
$schema .= $schema_insert;
}
$schema .= "\n";
}

if ($HTTP_POST_VARS['download'] == 'yes') {
$backup_file = 'db_' . DB_DATABASE . '-' . date('YmdHis') . '.sql';
switch ($HTTP_POST_VARS['compress']) {
case 'no':
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $backup_file);
echo $schema;
exit;
break;
case 'gzip':
if ($fp = fopen(DIR_FS_BACKUP . $backup_file, 'w')) {
fputs($fp, $schema);
fclose($fp);
exec(LOCAL_EXE_GZIP . ' ' . DIR_FS_BACKUP . $backup_file);
$backup_file .= '.gz';
}
if ($fp = fopen(DIR_FS_BACKUP . $backup_file, 'rb')) {
$buffer = fread($fp, filesize(DIR_FS_BACKUP . $backup_file));
fclose($fp);
unlink(DIR_FS_BACKUP . $backup_file);
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $backup_file);
echo $buffer;
exit;
}
break;
case 'zip':
if ($fp = fopen(DIR_FS_BACKUP . $backup_file, 'w')) {
fputs($fp, $schema);
fclose($fp);
exec(LOCAL_EXE_ZIP . ' -j ' . DIR_FS_BACKUP . $backup_file . '.zip ' . DIR_FS_BACKUP . $backup_file);
unlink(DIR_FS_BACKUP . $backup_file);
$backup_file .= '.zip';
}
if ($fp = fopen(DIR_FS_BACKUP . $backup_file, 'rb')) {
$buffer = fread($fp, filesize(DIR_FS_BACKUP . $backup_file));
fclose($fp);
unlink(DIR_FS_BACKUP . $backup_file);
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $backup_file);
echo $buffer;
exit;
}
}
} else {
$backup_file = DIR_FS_BACKUP . 'db_' . DB_DATABASE . '-' . date('YmdHis') . '.sql';
if ($fp = fopen($backup_file, 'w')) {
fputs($fp, $schema);
fclose($fp);
switch ($HTTP_POST_VARS['compress']) {
case 'gzip':
exec(LOCAL_EXE_GZIP . ' ' . $backup_file);
break;
case 'zip':
exec(LOCAL_EXE_ZIP . ' -j ' . $backup_file . '.zip ' . $backup_file);
unlink($backup_file);
}
}
$messageStack->add_session(SUCCESS_DATABASE_SAVED, 'success');
tep_redirect(tep_href_link(FILENAME_BACKUP));
}
break;
case 'restorenow':
case 'restorelocalnow':
tep_set_time_limit(0);

if ($HTTP_GET_VARS['action'] == 'restorenow') {
$read_from = $HTTP_GET_VARS['file'];
if (file_exists(DIR_FS_BACKUP . $HTTP_GET_VARS['file'])) {
$restore_file = DIR_FS_BACKUP . $HTTP_GET_VARS['file'];
$extension = substr($HTTP_GET_VARS['file'], -3);
if ( ($extension == 'sql') || ($extension == '.gz') || ($extension == 'zip') ) {
switch ($extension) {
case 'sql':
$restore_from = $restore_file;
$remove_raw = false;
break;
case '.gz':
$restore_from = substr($restore_file, 0, -3);
exec(LOCAL_EXE_GUNZIP . ' ' . $restore_file . ' -c > ' . $restore_from);
$remove_raw = true;
break;
case 'zip':
$restore_from = substr($restore_file, 0, -4);
exec(LOCAL_EXE_UNZIP . ' ' . $restore_file . ' -d ' . DIR_FS_BACKUP);
$remove_raw = true;
}

if ( ($restore_from) && (file_exists($restore_from)) && (filesize($restore_from) > 15000) ) {
$fd = fopen($restore_from, 'rb');
$restore_query = fread($fd, filesize($restore_from));
fclose($fd);
}
}
}
} elseif ($HTTP_GET_VARS['action'] == 'restorelocalnow') {
if ($HTTP_POST_FILES['sql_file']) {
$uploaded_file = $HTTP_POST_FILES['sql_file']['tmp_name'];
$read_from = basename($HTTP_POST_FILES['sql_file']['name']);
} elseif ($HTTP_POST_VARS['sql_file']) {
$uploaded_file = $HTTP_POST_VARS['sql_file'];
$read_from = basename($HTTP_POST_VARS['sql_file_name']);
} else {
$uploaded_file = $sql_file;
$read_from = basename($sql_file_name);
}
if ($uploaded_file != 'none') {
if (tep_is_uploaded_file($uploaded_file)) {
$restore_query = fread(fopen($uploaded_file, 'r'), filesize($uploaded_file));
}
}
}

if ($restore_query) {
$sql_array = array();
$sql_length = strlen($restore_query);
$pos = strpos($restore_query, ';');
for ($i=$pos; $i<$sql_length; $i++) {
if ($restore_query[0] == '#') {
$restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n")));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';')-1;
continue;
}
if ($restore_query[($i+1)] == "\n") {
for ($j=($i+2); $j<$sql_length; $j++) {
if (trim($restore_query[$j]) != '') {
$next = substr($restore_query, $j, 6);
if ($next[0] == '#') {
// find out where the break position is so we can remove this line (#comment line)
for ($k=$j; $k<$sql_length; $k++) {
if ($restore_query[$k] == "\n") break;
}
$query = substr($restore_query, 0, $i+1);
$restore_query = substr($restore_query, $k);
// join the query before the comment appeared, with the rest of the dump
$restore_query = $query . $restore_query;
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';')-1;
continue 2;
}
break;
}
}
if ($next == '') { // get the last insert query
$next = 'insert';
}
if ( (eregi('create', $next)) || (eregi('insert', $next)) || (eregi('drop t', $next)) ) {
$next = '';
$sql_array[] = substr($restore_query, 0, $i);
$restore_query = ltrim(substr($restore_query, $i+1));
$sql_length = strlen($restore_query);
$i = strpos($restore_query, ';')-1;
}
}
}

$tables_query = tep_db_query('show tables');
while ($tables = tep_db_fetch_array($tables_query)) {
list(,$table) = each($tables);
tep_db_query("drop table " . $table);
}

for ($i=0; $i<sizeof($sql_array); $i++) {
tep_db_query($sql_array[$i]);
}

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'DB_LAST_RESTORE'");
tep_db_query("insert into " . TABLE_CONFIGURATION . " values ('', 'Last Database Restore', 'DB_LAST_RESTORE', '" . $read_from . "', 'Last database restore file', '6', '', '', now(), '', '')");

if ($remove_raw) {
unlink($restore_from);
}
}

$messageStack->add_session(SUCCESS_DATABASE_RESTORED, 'success');
tep_redirect(tep_href_link(FILENAME_BACKUP));
break;
case 'download':
$extension = substr($HTTP_GET_VARS['file'], -3);
if ( ($extension == 'zip') || ($extension == '.gz') || ($extension == 'sql') ) {
if ($fp = fopen(DIR_FS_BACKUP . $HTTP_GET_VARS['file'], 'rb')) {
$buffer = fread($fp, filesize(DIR_FS_BACKUP . $HTTP_GET_VARS['file']));
fclose($fp);
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $HTTP_GET_VARS['file']);
echo $buffer;
exit;
}
} else {
$messageStack->add(ERROR_DOWNLOAD_LINK_NOT_ACCEPTABLE, 'error');
}
break;
case 'deleteconfirm':
if (strstr($HTTP_GET_VARS['file'], '..')) tep_redirect(tep_href_link(FILENAME_BACKUP));

tep_remove(DIR_FS_BACKUP . '/' . $HTTP_GET_VARS['file']);
if (!$tep_remove_error) {
$messageStack->add_session(SUCCESS_BACKUP_DELETED, 'success');
tep_redirect(tep_href_link(FILENAME_BACKUP));
}
break;
}
}

// check if the backup directory exists
$dir_ok = false;
if (is_dir(DIR_FS_BACKUP)) {
$dir_ok = true;
if (!is_writeable(DIR_FS_BACKUP)) $messageStack->add(ERROR_BACKUP_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_BACKUP_DIRECTORY_DOES_NOT_EXIST, 'error');
}
?>

<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/CSS" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TITLE; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_FILE_DATE; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_FILE_SIZE; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
</tr>
<?php
if ($dir_ok) {
$dir = dir(DIR_FS_BACKUP);
$contents = array();
while ($file = $dir->read()) {
if (!is_dir(DIR_FS_BACKUP . $file)) {
$contents[] = $file;
}
}
sort($contents);

for ($files=0; $files<sizeof($contents); $files++) {
$entry = $contents[$files];

$check = 0;

if (((!$HTTP_GET_VARS['file']) || ($HTTP_GET_VARS['file'] == $entry)) && (!$buInfo) && ($HTTP_GET_VARS['action'] != 'backup') && ($HTTP_GET_VARS['action'] != 'restorelocal')) {
$file_array['file'] = $entry;
$file_array['date'] = date(PHP_DATE_TIME_FORMAT, filemtime(DIR_FS_BACKUP . $entry));
$file_array['size'] = number_format(filesize(DIR_FS_BACKUP . $entry)) . ' bytes';
switch (substr($entry, -3)) {
case 'zip': $file_array['compression'] = 'ZIP'; break;
case '.gz': $file_array['compression'] = 'GZIP'; break;
default: $file_array['compression'] = TEXT_NO_EXTENSION; break;
}

$buInfo = new objectInfo($file_array);
}

if (is_object($buInfo) && ($entry == $buInfo->file)) {
echo ' <tr class="dataTableRowSelected" onmou搜索引擎优化ver="this.style.cursor='hand'">' . "\n";
$onclick_link = 'file=' . $buInfo->file . '&action=restore';
} else {
echo ' <tr class="dataTableRow" onmou搜索引擎优化ver="this.className='dataTableRowOver';this.style.cursor='hand'" onmou搜索引擎优化ut="this.className='dataTableRow'">' . "\n";
$onclick_link = 'file=' . $entry;
}
?>
<td class="dataTableContent" onclick="document.location.href='<?php echo tep_href_link(FILENAME_BACKUP, $onclick_link); ?>'"><?php echo '<a href="' . tep_href_link(FILENAME_BACKUP, 'action=download&file=' . $entry) . '">' . tep_image(DIR_WS_ICONS . 'file_download.gif', ICON_FILE_DOWNLOAD) . '</a> ' . $entry; ?></td>
<td class="dataTableContent" align="center" onclick="document.location.href='<?php echo tep_href_link(FILENAME_BACKUP, $onclick_link); ?>'"><?php echo date(PHP_DATE_TIME_FORMAT, filemtime(DIR_FS_BACKUP . $entry)); ?></td>
<td class="dataTableContent" align="right" onclick="document.location.href='<?php echo tep_href_link(FILENAME_BACKUP, $onclick_link); ?>'"><?php echo number_format(filesize(DIR_FS_BACKUP . $entry)); ?> bytes</td>
<td class="dataTableContent" align="right"><?php if ( (is_object($buInfo)) && ($entry == $buInfo->file) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $entry) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
</tr>
<?php
}
$dir->close();
}
?>
<tr>
<td class="smallText" colspan="3"><?php echo TEXT_BACKUP_DIRECTORY . ' ' . DIR_FS_BACKUP; ?></td>
<td align="right" class="smallText"><?php if ( ($HTTP_GET_VARS['action'] != 'backup') && ($dir) ) echo '<a href="' . tep_href_link(FILENAME_BACKUP, 'action=backup') . '">' . tep_image_button('button_backup.gif', IMAGE_BACKUP) . '</a>'; if ( ($HTTP_GET_VARS['action'] != 'restorelocal') && ($dir) ) echo '  <a href="' . tep_href_link(FILENAME_BACKUP, 'action=restorelocal') . '">' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . '</a>'; ?></td>
</tr>
<?php
if (defined('DB_LAST_RESTORE')) {
?>
<tr>
<td class="smallText" colspan="4"><?php echo TEXT_LAST_RESTORATION . ' ' . DB_LAST_RESTORE . ' <a href="' . tep_href_link(FILENAME_BACKUP, 'action=forget') . '">' . TEXT_FORGET . '</a>'; ?></td>
</tr>
<?php
}
?>
</table></td>
<?php
$heading = array();
$contents = array();
switch ($HTTP_GET_VARS['action']) {
case 'backup':
$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_BACKUP . '</b>');

$contents = array('form' => tep_draw_form('backup', FILENAME_BACKUP, 'action=backupnow'));
$contents[] = array('text' => TEXT_INFO_NEW_BACKUP);

if ($messageStack->size > 0) {
$contents[] = array('text' => '<br>' . tep_draw_radio_field('compress', 'no', true) . ' ' . TEXT_INFO_USE_NO_COMPRESSION);
$contents[] = array('text' => '<br>' . tep_draw_radio_field('download', 'yes', true) . ' ' . TEXT_INFO_DOWNLOAD_ONLY . '*<br><br>*' . TEXT_INFO_BEST_THROUGH_HTTPS);
} else {
$contents[] = array('text' => '<br>' . tep_draw_radio_field('compress', 'gzip', true) . ' ' . TEXT_INFO_USE_GZIP);
$contents[] = array('text' => tep_draw_radio_field('compress', 'zip') . ' ' . TEXT_INFO_USE_ZIP);
$contents[] = array('text' => tep_draw_radio_field('compress', 'no') . ' ' . TEXT_INFO_USE_NO_COMPRESSION);
$contents[] = array('text' => '<br>' . tep_draw_checkbox_field('download', 'yes') . ' ' . TEXT_INFO_DOWNLOAD_ONLY . '*<br><br>*' . TEXT_INFO_BEST_THROUGH_HTTPS);
}

$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_backup.gif', IMAGE_BACKUP) . ' <a href="' . tep_href_link(FILENAME_BACKUP) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
case 'restore':
$heading[] = array('text' => '<b>' . $buInfo->date . '</b>');

$contents[] = array('text' => tep_break_string(sprintf(TEXT_INFO_RESTORE, DIR_FS_BACKUP . (($buInfo->compression != TEXT_NO_EXTENSION) ? substr($buInfo->file, 0, strrpos($buInfo->file, '.')) : $buInfo->file), ($buInfo->compression != TEXT_NO_EXTENSION) ? TEXT_INFO_UNPACK : ''), 35, ' '));
$contents[] = array('align' => 'center', 'text' => '<br><a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $buInfo->file . '&action=restorenow') . '">' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . '</a> <a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $buInfo->file) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
case 'restorelocal':
$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_RESTORE_LOCAL . '</b>');

$contents = array('form' => tep_draw_form('restore', FILENAME_BACKUP, 'action=restorelocalnow', 'post', 'enctype="multipart/form-data"'));
$contents[] = array('text' => TEXT_INFO_RESTORE_LOCAL . '<br><br>' . TEXT_INFO_BEST_THROUGH_HTTPS);
$contents[] = array('text' => '<br>' . tep_draw_file_field('sql_file'));
$contents[] = array('text' => TEXT_INFO_RESTORE_LOCAL_RAW_FILE);
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_restore.gif', IMAGE_restore) . ' <a href="' . tep_href_link(FILENAME_BACKUP) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
case 'delete':
$heading[] = array('text' => '<b>' . $buInfo->date . '</b>');

$contents = array('form' => tep_draw_form('delete', FILENAME_BACKUP, 'file=' . $buInfo->file . '&action=deleteconfirm'));
$contents[] = array('text' => TEXT_DELETE_INTRO);
$contents[] = array('text' => '<br><b>' . $buInfo->file . '</b>');
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $buInfo->file) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
default:
if (is_object($buInfo)) {
$heading[] = array('text' => '<b>' . $buInfo->date . '</b>');

$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $buInfo->file . '&action=restore') . '">' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . '</a> <a href="' . tep_href_link(FILENAME_BACKUP, 'file=' . $buInfo->file . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
$contents[] = array('text' => '<br>' . TEXT_INFO_DATE . ' ' . $buInfo->date);
$contents[] = array('text' => TEXT_INFO_SIZE . ' ' . $buInfo->size);
$contents[] = array('text' => '<br>' . TEXT_INFO_COMPRESSION . ' ' . $buInfo->compression);
}
break;
}

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo ' <td width="25%" valign="top">' . "\n";

$box = new box;
echo $box->infoBox($heading, $contents);

echo ' </td>' . "\n";
}
?>
</tr>
</table></td>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

  咱们就开始学习动态语言的概念吧,刚一接触动态语言,可能很多人都会蒙了,怎么这乱七八糟的东西,在网页里显示的时候却是另外一码事?其实这并不算乱七八糟,你写的HTML代码不也一样是一堆堆的字符吗?毕竟,代码并不是作为直接输出的,而是经过处理的,说白了,HTML是经过HTML解析器,而PHP当然也就通过PHP解析器了,跟学习HTML一样的道理,想让任何的解析器完成操作,就必须使用它们专用的语法结构,所以PHP长相奇怪也就不足为奇了。
只想知道 该用户已被删除
沙发
发表于 2015-2-4 11:15:23 | 只看该作者
php是动态网站开发的优秀语言,在学习的时候万万不能冒进。在系统的学习前,我认为不应该只是追求实现某种效果,因为即使你复制他人的代码调试成功,实现了你所期望的效果,你也不了解其中的原理。
变相怪杰 该用户已被删除
板凳
发表于 2015-2-9 22:19:33 | 只看该作者
最后介绍一个代码出错,但是老找不到错误方法,就是 go to wc (囧),出去换换气没准回来就找到错误啦。
蒙在股里 该用户已被删除
地板
发表于 2015-2-11 20:08:17 | 只看该作者
因为blog这样的可以让你接触更多要学的知识,可以接触用到类,模板,js ,ajax
山那边是海 该用户已被删除
5#
发表于 2015-3-2 18:11:20 | 只看该作者
曾经犯过一个很低级的错误,我在文件命名的时候用了一个横线\\\\\\\'-\\\\\\\' 号,结果找了好几个小时的错误,事实是命名的时候 是不能用横线 \\\\\\\'-\\\\\\\' 的,应该用的是下划线  \\\\\\\'_\\\\\\\' ;
活着的死人 该用户已被删除
6#
发表于 2015-3-6 21:35:25 | 只看该作者
这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。
小女巫 该用户已被删除
7#
发表于 2015-3-10 13:05:47 | 只看该作者
曾经犯过一个很低级的错误,我在文件命名的时候用了一个横线\\\\\\\'-\\\\\\\' 号,结果找了好几个小时的错误,事实是命名的时候 是不能用横线 \\\\\\\'-\\\\\\\' 的,应该用的是下划线  \\\\\\\'_\\\\\\\' ;
飘灵儿 该用户已被删除
8#
发表于 2015-3-12 11:08:39 | 只看该作者
当留言板完成的时候,下步可以把做1个单人的blog程序,做为目标,
再现理想 该用户已被删除
9#
发表于 2015-3-19 20:52:38 | 只看该作者
首推的搜索引擎当然是Google大神,其次我比较喜欢 百度知道。不过搜出来的结果往往都是 大家copy来copy去的,运气的的概率很大。
乐观 该用户已被删除
10#
发表于 2015-3-22 20:38:05 | 只看该作者
有时候汉字的空格也能导致页面出错,所以在写代码的时候,要输入空格最好用引文模式。
金色的骷髅 该用户已被删除
11#
发表于 2015-3-27 10:33:34 | 只看该作者
对于懒惰的朋友,我推荐php的集成环境xampp或者是wamp。这两个软件安装方便,使用简单。但是我还是强烈建议自己动手搭建开发环境。
灵魂腐蚀 该用户已被删除
12#
发表于 2015-4-4 14:05:31 | 只看该作者
有位前辈曾经跟我说过,phper 至少要掌握200个函数 编起程序来才能顺畅点,那些不熟悉的函数记不住也要一拿手册就能找到。所以建议新手们没事就看看php的手册(至少array函数和string函数是要记牢的)。
分手快乐 该用户已被删除
13#
发表于 2015-4-4 17:00:22 | 只看该作者
兴趣是最好的老师,百度是最好的词典。
爱飞 该用户已被删除
14#
发表于 2015-4-11 08:27:18 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
飘飘悠悠 该用户已被删除
15#
发表于 2015-4-16 22:11:57 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
兰色精灵 该用户已被删除
16#
发表于 2015-4-22 12:39:35 | 只看该作者
php是动态网站开发的优秀语言,在学习的时候万万不能冒进。在系统的学习前,我认为不应该只是追求实现某种效果,因为即使你复制他人的代码调试成功,实现了你所期望的效果,你也不了解其中的原理。
深爱那片海 该用户已被删除
17#
发表于 2015-5-5 06:48:53 | 只看该作者
使用 jquery 等js框架的时候,要随时注意浏览器的更新情况,不然很容易发生框架不能使用。
admin 该用户已被删除
18#
发表于 2015-6-25 21:42:02 | 只看该作者
真正的方向了,如果将来要去开发团队,你一定要学好smarty ,phplib这样的模板引擎,
19#
发表于 2015-7-1 03:06:50 | 只看该作者
为了以后维护的方便最好是代码上都加上注释,“予人方便,自己方便”。此外开发文档什么的最好都弄齐全。我觉得这是程序员必备的素质。虽然会消耗点很多的时间。但是确实是非常有必要的。
小妖女 该用户已被删除
20#
发表于 2015-7-5 01:19:18 | 只看该作者
这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-23 03:13

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表