Can I use PHP print as Input Field's default Value?
<p>I have placed a php code for getting current page URL and now I can get current page URL by writing this code</p>

<pre><code>&lt;?php print(selfURL()); ?&gt;
</code></pre>

<p>Now, I want to know how can I write this code as the default value of Input field?
Actually I want the Input field to automatically filled up with the current page URL. </p>

<p>When I use <code>&lt;?php print(selfURL()); ?&gt;</code> as <code>value="&lt;?php print(selfURL()); ?&gt;"</code> it simple shows a text and don't display current url. But when I paste it in other place then its working fine.</p>

<p>Any suggestions?</p>

<p>UpDATE:</p>

<p>Guys, this is the full code of the page, may be it helps!</p>

<pre><code>&lt;?php
function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); }
?&gt;
&lt;?php 
// Start YOURLS engine
require_once( dirname(__FILE__).'/includes/load-yourls.php' );
?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;YOURLS Public Interface Sample&lt;/title&gt;
&lt;style&gt;
body {
    background:#E3F3FF;
    color:#595441;
    font:16px/30px verdana,arial,sans-serif;
}
a, a:visited {color:#2A85B3}
h1 {text-align:center; color:#2A85B3}
h2 {
    border-bottom:1px solid #2A85B3;
    color:#2A85B3;
    margin-left:-10px;
    padding-left:25px;
    width:80%;
}
#container {
    width: 780px;
    margin-left: auto;
    margin-right: auto; 
    background-color: #fff;
    border: 3px solid #2A85B3;
    padding: 10px;
    margin-top: -13px;
    -moz-border-radius:15px;
    -webkit-border-radius:15px;
}
#footer {
    text-align:center;
    margin-top:20px;
}
#footer p {
    padding:5px;
    background:white;
    margin:0 auto;
    width:750px;
    -moz-border-radius:10px;
    border-radius:10px;
    -webkit-border-radius:10px;
    border:1px solid #2A85B3;
    -moz-border-radius-bottomleft:35px;
    -moz-border-radius-bottomright:35px;
    -webkit-border-bottom-left-radius:25px;
    -webkit-border-bottom-right-radius:25px;
}
#footer p a {
    background:#fff url(http://yourls.org/images/favicon.gif) 2px center no-repeat;
    padding-left:20px;
}
div#copybox { width:600px; height:auto;}
div#sharebox {height:auto; width:600px; margin-top:20px;}
&lt;/style&gt;
&lt;link rel="stylesheet" href="&lt;?php echo YOURLS_SITE; ?&gt;/css/share.css?v=&lt;?php echo YOURLS_VERSION; ?&gt;" type="text/css" media="screen" /&gt;
&lt;script src="&lt;?php echo YOURLS_SITE; ?&gt;/js/jquery-1.6.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="&lt;?php echo YOURLS_SITE; ?&gt;/js/ZeroClipboard.js?v=&lt;?php echo YOURLS_VERSION; ?&gt;" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;ZeroClipboard.setMoviePath( '&lt;?php echo YOURLS_SITE; ?&gt;/js/ZeroClipboard.swf' );&lt;/script&gt;
&lt;script src="&lt;?php echo YOURLS_SITE; ?&gt;/js/share.js?v=&lt;?php echo YOURLS_VERSION; ?&gt;" type="text/javascript"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;YOURLS: Your Own URL Shortener&lt;/h1&gt;

&lt;div id="container"&gt;

    &lt;?php

    // Part to be executed if FORM has been submitted
    if ( isset($_REQUEST['url']) ) {

        $url     = yourls_sanitize_url( $_REQUEST['url'] );

        $return  = yourls_add_new_link( $url );

        $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';


        echo &lt;&lt;&lt;RESULT
        &lt;h2&gt;URL has been shortened&lt;/h2&gt;
        &lt;p&gt;Original URL: &lt;code&gt;&lt;a href="$url"&gt;$url&lt;/a&gt;&lt;/code&gt;&lt;/p&gt;
        &lt;p&gt;Short URL: &lt;code&gt;&lt;a href="$shorturl"&gt;$shorturl&lt;/a&gt;&lt;/code&gt;&lt;/p&gt;

RESULT;



    // Part to be executed when no form has been submitted
    } else {

        $site = YOURLS_SITE;

        echo &lt;&lt;&lt;HTML
        &lt;h2&gt;Enter a new URL to shorten&lt;/h2&gt;
        &lt;form method="post" action=""&gt;
        &lt;p&gt;&lt;label&gt;URL: &lt;input type="text" name="url" value="&lt;?php echo selfURL(); ?&gt;" size="70" /&gt;&lt;/label&gt;&lt;/p&gt;
        &lt;p&gt;&lt;label&gt;Optional custom keyword: $site/&lt;input type="text" name="keyword" size="8" /&gt;&lt;/label&gt;&lt;/p&gt;
        &lt;p&gt;&lt;label&gt;Optional title: &lt;input type="text" name="title" size="57" /&gt;&lt;/label&gt;&lt;/p&gt;
        &lt;p&gt;&lt;input type="submit" value="Shorten" /&gt;&lt;/p&gt;
        &lt;/form&gt; 
HTML;

    }

    ?&gt;


&lt;/div&gt;





&lt;?php print(selfURL()); ?&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
