首页 > 怎么用最简短的代码写一个程序输出程序本身?

怎么用最简短的代码写一个程序输出程序本身?

写一个程序输出自己本身的代码。最好是脚本语言。


#!/bin/cat
doewujdoweijdoweijdoweijdowejdoiwe

哈哈,自问自答。


整个shell的

#!/bin/bash
cat $0

再整个php的

<?php
$fileContents = file_get_contents(__FILE__);
echo $fileContents;

最后赠送个perl的

#!/usr/bin/perl
use FindBin qw($Bin);
open (LOGFILE, $Bin . "/" . $0);
$line = <LOGFILE>;
while(<LOGFILE>) {
    print $line;
    $line = <LOGFILE>;
}

<?php
#php天生的优势
highlight_file(__FILE__);
【热门文章】
【热门文章】