php소스 질문이요 ㅠ

php소스 질문이요 ㅠ

QA

php소스 질문이요 ㅠ

본문

<?php
define('PHURL', true);
ini_set('display_errors', 0);
$prefix[0] = '';
$filename = 'install';
if (is_dir($filename)) {
    die ("To get Phurl up and running, you first need to go through the <a href=\"install\">installation wizard</a> which will help you set up your new URL shortener in a matter of moments.<br/><br/>If you've already installed Phurl, then you MUST delete the install directory before it will function.");
}
?>
<?php
require_once("config.php");
require_once("functions.php");
db_connect();
if (count($_GET) > 0) {
    $url   = mysql_real_escape_string(trim($_GET['url']));
    $alias = mysql_real_escape_string(trim($_GET['alias']));
    if (!preg_match("/^(".URL_PROTOCOLS.")\:\/\//i", $url)) {
  $prefix = explode(":", $url);
  if ($prefix[0] == 'mailto') {
   $url = $url;
  } else {
        $url = "http://".$url;
  }
    }
    $last = $url[strlen($url) - 1];
    if ($last == "/") {
        $url = substr($url, 0, -1);
    }
    $data = @parse_url($url);
  if ($prefix[0] == 'mailto') {
   $data['scheme'] = 'mailto';
   $data['host'] = 'none';
  }
    if (strlen($url) == 0) {
        $_ERROR[] = "Please enter a URL to shorten.";
    }
    else if (empty($data['scheme']) || empty($data['host'])) {
        $_ERROR[] = "Please enter a valid URL to shorten.";
    }
    else {
        $hostname = get_hostname();
        $domain   = get_domain();
        if (preg_match("/($hostname)/i", $data['host'])) {
            $_ERROR[] = "The URL you have entered is not allowed.";
        }
    }
    if (strlen($alias) > 0) {
        if (!preg_match("/^[a-zA-Z0-9_-]+$/", $alias)) {
            $_ERROR[] = "Custom aliases may only contain letters, numbers, underscores and dashes.";
        }
        else if (code_exists($alias) || alias_exists($alias)) {
            $_ERROR[] = "The custom alias you entered already exists.";
        }
    }
    if (count($_ERROR) == 0) {
        $create = true;
        if (($url_data = url_exists($url))) {
            $create    = false;
            $id        = $url_data[0];
            $code      = $url_data[1];
            $old_alias = $url_data[2];
            if (strlen($alias) > 0) {
                if ($old_alias != $alias) {
                    $create = true;
                }
            }
        }
        if ($create) {
            do {
                $code = generate_code(get_last_number());
                if (!increase_last_number()) {
                    die("System error!");
                }
                if (code_exists($code) || alias_exists($code)) {
                    continue;
                }
                break;
            } while (1);
            $id = insert_url($url, $code, $alias);
        }
        if (strlen($alias) > 0) {
            $code = $alias;
        }
        $short_url = SITE_URL."/".$code;
        $_GET['url']   = "";
        $_GET['alias'] = "";
        require_once("html/header.php");
        require_once("html/index_done.php");
        require_once("html/index_form.php");
        require_once("html/footer.php");
        exit();
    }
}
require_once("html/header.php");
require_once("html/index_form.php");
require_once("html/footer.php");


위 소스에서   $_ERROR[] = "Please enter a valid URL to shorten."; 오류메시지를 php에서 불러오게 하고싶은데 어떻게 하면될까요?

$_ERROR[] = require_once("html/error1.php"); 이렇게 해봤으나 밑에 숫자1이 나오네요;;

부탁드립니다 ㅠ

 

이 질문에 댓글 쓰기 :

답변 1

내용은 길어 읽지 않았습니다 ㅎㅎ

$_ERROR[] = require_once("html/error1.php");//1 리턴 한다는 것은 성공적으로

error1.php불러 왔다는 겁니다.

다시 얘기하면 require_once가 성공하면 true, 실패하면 false값을 리턴하기 때문이죠.

 

error1.php 파일 내에 $_ERROR = array();로 선언하고

사용하셔야 할 듯 하군요.

require_once("html/error1.php");

$ERROR = "추가할 에러 내용"; 이런 식으로 사용하셔야 할 듯... 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 5

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT