コード例 #1
0
ファイル: JS.php プロジェクト: rex786/php2js
    echo "Test multi-line JS() code inside heredoc<br>\n";
    echo 'result: ' . ($i === 10 ? 'pass' : 'fail') . "<br><br>\n\n";
}
function test4()
{
    JS("\n       for( var i = 0; i < 10; i++) {\n        i ++;\n       }\n");
    echo "Test multi-line JS() code inside double-quoted string<br>\n";
    echo 'result: ' . ($i === 10 ? 'pass' : 'fail') . "<br><br>\n\n";
}
function test5()
{
    // Uncomment to test that php->js compiler correctly throws an exception when string is not constant.
    /*    
        $start = 3;
        JS("
           for( var i = $start; i < 10; i++) {
            i ++;
           }
    "
        );
        
        echo "Test multi-line JS() code inside double quoted string with embedded var.  Should throw an exception when compiling.<br>\n";
        echo 'result: ' . ($i === 10 ? 'pass' : 'fail') . "<br><br>\n\n";
    */
}
test1();
test2();
test3();
test4();
test5();
コード例 #2
0
ファイル: function.php プロジェクト: masa69/php-sample
function test()
{
    // ERROR: Notice
    var_dump($value);
}
// test();
function test2($prefix, $val)
{
    return "{$prefix}_{$val}\n";
}
echo test2('test2', $value);
function test3($val)
{
    return test2('test3', $val);
}
// echo test3($value);
function test4()
{
    function innerFunc($val, $x, $y)
    {
        return test2($val, $x + $y);
    }
    return innerFunc('test4', 1, 2);
}
// echo test4();
function test5()
{
    return innerFunc('test5', 10, 101);
}
echo test5();
コード例 #3
0
    if (isLvl5("Heavy Drone Operation")) {
        echo "Has T2 Heavies<br>\n";
    } else {
        test5("Heavy Drone Operation", "Heavy Drones");
    }
    if (isLvl5("Sentry Drone Interfacing")) {
        echo "Has T2 Sentries<br>\n";
    } else {
        test5("Sentry Drone Interfacing", "Sentry Drones");
    }
    if (isLvl5("Fighters") && skillLvl("Fighter Bombers") != -1) {
        test5("Fighter Bombers", "Fighter Bombers");
    } else {
        test5("Fighters", "Fighters");
    }
    test5("Drone Interfacing");
}
$delim = "&nbsp;";
$delim = "</td><td>";
echo "<br><table><tr><td>WU/AWU:</td><td>";
echo skillLvl("Weapon Upgrades") . $delim;
echo skillLvl("Advanced Weapon Upgrades");
echo "</td></tr><tr><td>ELC/ENG:</td><td>";
echo skillLvl("Electronics") . $delim;
echo skillLvl("Engineering");
echo "</td></tr></table><br>Support skills:\n<br><table style=\"font-size:95%\"><tr>";
echo "<td>turr&nbsp;</td><td>";
echo skillLvl("Controlled Bursts") . $delim;
echo skillLvl("Gunnery") . $delim;
echo skillLvl("Motion Prediction") . $delim;
echo skillLvl("Rapid Firing") . $delim;
コード例 #4
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// ****************************************************************************
echo "<h4>Modules</h4><hr><span style=\"font-size:90%\">\n";
if (isLvl5("Anchoring") && skillLvl("Starbase Defense Management") != -1) {
    test5("Starbase Defense Management", "Pos Guns");
}
test("Cynosural Field Generator I", "Cyno Gen");
echo "<br>";
if (!test2("100MN Microwarpdrive II", "T2 MWDs")) {
    test("100MN Microwarpdrive I", "T1 MWDs");
}
test("Large Shield Extender II", "LSE II");
test("Invulnerability Field II", "Invuln II");
test("Energized Adaptive Nano Membrane II", "EANM II");
test("Damage Control II", "DCU II");
test("1600mm Reinforced Rolled Tungsten Plates I", "1600mm RT");
test("Sensor Booster II", "SB II");
test("Tracking Computer II", "TC II");
test("Tracking Enhancer II", "TE II");
test("Power Diagnostic System II", "PDU II");
コード例 #5
0
ファイル: bug42802.php プロジェクト: badlamer/hhvm
class bar
{
}
function test1(bar $bar)
{
    echo "ok\n";
}
function test2(\foo\bar $bar)
{
    echo "ok\n";
}
function test3(\foo\bar $bar)
{
    echo "ok\n";
}
function test4(\Exception $e)
{
    echo "ok\n";
}
function test5(\bar $bar)
{
    echo "bug\n";
}
$x = new bar();
$y = new \Exception();
test1($x);
test2($x);
test3($x);
test4($y);
test5($x);
コード例 #6
0
ファイル: 166.php プロジェクト: badlamer/hhvm
    return $buf;
}
var_dump(test1(array(1)));
function test2()
{
    return f() . g() . f() . g();
}
var_dump(test2());
function test3()
{
    return f() . g() . f() . g() . f() . g() . f() . g() . f();
}
var_dump(test3());
function test4()
{
    $s = f();
    $s .= 'foo' . 'bar' . f() . 'foo' . 'baz' . f() . 'fuz' . 'boo' . f() . 'fiz' . 'faz';
    $s .= f();
    return $s;
}
var_dump(test4());
function test5()
{
    return g() . g() . g() . g();
}
var_dump(test5());
function test6()
{
    return g() . f() . g();
}
var_dump(test6());