Esempio n. 1
0
        echo "Goodbye " . $this->message;
    }
}
$test = new TestClass("cruel world!");
//https://github.com/Danack/PHP-to-Javascript/issues/44
//Embedded variables
$value1 = 5;
$value2 = "Hello " . $value1 . " there";
assert($value2, "Hello 5 there");
$value3 = "Hello {$value1} there";
assert($value3, "Hello 5 there");
function greet($name)
{
    return "Hello {$name}!";
}
assert(greet("Bob"), "Hello Bob!");
//https://github.com/Danack/PHP-to-Javascript/issues/14
//Modulus doesn't work
$p2 = 8;
$step = 6;
$p2 -= $p2 % $step;
//assert($p2, 6);
//*************************************************************
//*************************************************************
//https://github.com/Danack/PHP-to-Javascript/issues/15
$countValue = 4;
$countValue--;
//assert($countValue, 3);
$countValue--;
//assert($countValue, 2);
//https://github.com/Danack/PHP-to-Javascript/issues/48
Esempio n. 2
0
<?php

function greet($now)
{
    print "Hello world @ " . date("d-M-Y H:i:s", $now);
}
greet(time());
Esempio n. 3
0
<?php

function greet($name)
{
    echo 'Hi ' . $name;
}
greet('bambang');
Esempio n. 4
0
require_once "app/views/helper.php";
require_once "app/base.php";
date_default_timezone_set("UTC");
#overridden later if user specify his
try {
    Zend_Session::start();
    ini_set('error_log', config()->error_logfile);
    ini_set('display_errors', 0);
    ini_set('log_errors', 1);
    ini_set('display_startup_errors', 1);
    ini_set('default_charset', 'UTF-8');
    ini_set('default_socket_timeout', 120);
    remove_quotes();
    fix_eol();
    setup_logs();
    greet();
    cert_authenticate();
    /*
    if(!date_default_timezone_set(user()->getTimeZone())) {
        addMessage("Your timezone '".user()->getTimeZone()."' is not valid. Please try using location based timezone such as 'America/Chicago'. Reverting to UTC.");
    }
    */
    error_reporting(E_ALL | E_STRICT);
} catch (exception $e) {
    /*
        //when a catastrohpic failure occure (like disk goes read-only..) emailing is the only way we got..
        if(!config()->debug) {
            mail(config()->elog_email_address, "[gocticket] Caught exception during bootstrap", $e, "From: ".config()->email_from);
        }
    */
    header("HTTP/1.0 500 Internal Server Error");
// require 'TablePrinet.php';
class Greeting
{
    public function greet($name)
    {
        return 'Hello, ' . $name;
    }
}
class LessFormalGreeting extends Greeting
{
    public function greet($name)
    {
        return 'Sup, ' . $name;
    }
}
class PirateGreeting extends Greeting
{
    public function greet($name)
    {
        return 'Welcome aboard, me matey ' . $name;
    }
}
function greet(Greeting $greeting, $name = 'Someone')
{
    return $greeting->greet($name);
}
echo "Greeting: " . greet(new Greeting()) . PHP_EOL;
echo "LessFormalGreeting: " . greet(new LessFormalGreeting()) . PHP_EOL;
echo "PirateGreeting: " . greet(new PirateGreeting()) . PHP_EOL;
Esempio n. 6
0
<?php

function greet($name)
{
    echo "Hello, {$name}\n";
}
greet("Janet");
Esempio n. 7
0
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
require dirname(__FILE__) . '/vendor/autoload.php';
require dirname(__FILE__) . '/helloworld.php';
function greet($name)
{
    $client = new helloworld\GreeterClient('localhost:50051', ['credentials' => Grpc\ChannelCredentials::createInsecure()]);
    $request = new helloworld\HelloRequest();
    $request->setName($name);
    list($reply, $status) = $client->SayHello($request)->wait();
    $message = $reply->getMessage();
    return $message;
}
$name = !empty($argv[1]) ? $argv[1] : 'world';
print greet($name) . "\n";
Esempio n. 8
0
<?php

echo greet(date("H"), true);
function greet($hour, $html = false)
{
    $msg = '';
    if ($html) {
        $msg .= '<h1>';
    }
    $postfix = 'th';
    if ($hour == 1) {
        $postfix = 'st';
    } elseif ($hour == '2') {
        $postfix = 'nd';
    } elseif ($hour == 3) {
        $postfix = 'rd';
    }
    $msg .= 'You are in the ' . $hour . $postfix . ' hour: ';
    if ($hour < 12 && $hour > 7) {
        $msg .= 'Good Morning';
    } elseif ($hour < 20) {
        $msg .= 'Good Afternoon';
    } else {
        $msg .= 'Good Night';
    }
    if ($html) {
        $msg .= '</h1>';
    }
    return $msg;
}
Esempio n. 9
0
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
require dirname(__FILE__) . '/vendor/autoload.php';
require dirname(__FILE__) . '/helloworld.php';
function greet($name)
{
    $client = new helloworld\GreeterClient('localhost:50051', ['credentials' => Grpc\ChannelCredentials::createInsecure()]);
    $request = new helloworld\HelloRequest();
    $request->setName($name);
    list($reply, $status) = $client->SayHello($request)->wait();
    $message = $reply->getMessage();
    return $message;
}
$name = !empty($argv[1]) ? $argv[1] : 'world';
echo greet($name) . "\n";
Esempio n. 10
0
<?php

// basic.php
function greet() : string
{
    return "G'day world";
}
echo greet();
Esempio n. 11
0
<?php

require '../../autoloader.php';
$conn = new Metaregistrar\EPP\iisEppConnection();
// Connect to the EPP server
if ($conn->connect()) {
    if (greet($conn)) {
        if (login($conn)) {
            echo "Test 1: Create domain name with subordinate hosts\n";
            test1($conn, 'fte236937-eca49a10f5cbc2fb8371e6817b9ec54e-01.nu');
            #echo "Test 2: Update contact with telephone and postal code\n";
            #test2($conn,'');
            #echo "Test 3: Add ip 217.108.99.249 , 2001:698:a:e:208:2ff:fe15:b2e8 to host\n";
            #test3($conn, '');
            #echo "Test 4: Add host primary.nu to domain\n";
            #test4($conn, '');
            #echo "Test 5: Remove host testhost from domain\n";
            #test5($conn, '');
            #echo "Test 6: Change the owner of domain \n";
            #test6($conn, '');
            #echo "Test 7: Renew domain\n";
            #test7($conn,'');
            #echo "Test 8: Set client delete for domain\n";
            #test8($conn, '');
            #echo "Test 9: Clear client delete for domain\n";
            #test9($conn, '');
            #echo "Test 10: Request transfer of domain with authInfo\n";
            #test10($conn, '.nu', '');
            #echo "Test 11: Remove DS records from domain \n";
            #test11($conn,'.nu');
            #echo "Test 12: Set authInfo for domain\n";