Calling java script in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Dormilich
    replied
    that depends on what’s inside myfile.php

    Leave a comment:


  • Dheeraj Joshi
    replied
    Ok.. Markus... Then what does this return?

    Code:
    `php myfile.php`

    A string or ............... ..?


    Regards
    Dheeraj Joshi

    Leave a comment:


  • Dormilich
    replied
    Originally posted by Markus
    Actually, back-ticks, like in other languages, do run the contents as a shell command.
    interesting, need to make a (mental) note of that.

    Leave a comment:


  • Markus
    replied
    Originally posted by Dormilich
    actually… no. if you want to ‘execute’ a file you need to load/include it. and that doesn’t return a value…
    Code:
    // 4 different ways to include a file
    include "file.php";
    include_once "file.php";
    require "file.php";
    require_once "file.php";
    and backticks are not valid string delimiters.

    the only constructs able to return a value are variables, constants, functions, properties and methods (the latter 2 being special cases from to objects)
    Actually, back-ticks, like in other languages, do run the contents as a shell command.

    Code:
    printf("PHP is located at %s", `which php`);
    // equivalent of doing
    printf("PHP is located at %s", shell_exec('which php'));

    Leave a comment:


  • Dormilich
    replied
    take it out of the switch(), currently that’s preventing the print.

    Leave a comment:


  • Markus
    replied
    Originally posted by dheerajjoshim
    yeah Mark..

    I a gave that echo still it do not give anything.

    Regards
    Dheeraj Joshi
    Post the new code (using [code] tags).

    Leave a comment:


  • Dheeraj Joshi
    replied
    yeah Mark..

    I a gave that echo still it do not give anything.

    Regards
    Dheeraj Joshi

    Leave a comment:


  • Jezternz
    replied
    I have either missed something obvious, or the javascript tag is completly wrong.
    Code:
    "<scriptlanguage=javascript> 
            alert('Blah Blah')
    </script>";
    Should be:
    Code:
    echo "<script type=\"text/javascript\">
            alert('Blah Blah')
    </script>";

    Leave a comment:


  • Markus
    replied
    Originally posted by dheerajjoshim
    Ok.. Thanks..

    Back to my java script problem?

    How i have embedded the java script, is it correct?

    Regards
    Dheeraj Joshi
    You're missing the echo/print call in the case.

    Leave a comment:


  • Dormilich
    replied
    if you don’t need a condition, just echo it out.

    Leave a comment:


  • Dheeraj Joshi
    replied
    Ok.. Thanks..

    Back to my java script problem?

    How i have embedded the java script, is it correct?

    Regards
    Dheeraj Joshi

    Leave a comment:


  • Dormilich
    replied
    Originally posted by dheerajjoshim
    So this basically must hold the return value of function myfun() in myfile.
    let’s say that myfun() must return a value.

    so the code now looks sensible.

    Leave a comment:


  • Dheeraj Joshi
    replied
    You mean,

    Code:
    include("myfile.php");
    
    $res=myfile::myfun();
    So this basically must hold the return value of function myfun() in myfile.

    Regards
    Dheeraj Joshi

    Leave a comment:


  • Dormilich
    replied
    Originally posted by dheerajjoshim
    Code:
    $res=`php myfile.php`
    it executes file named myfile.php and gives the result back.
    actually… no. if you want to ‘execute’ a file you need to load/include it. and that doesn’t return a value…
    Code:
    // 4 different ways to include a file
    include "file.php";
    include_once "file.php";
    require "file.php";
    require_once "file.php";
    and backticks are not valid string delimiters.

    the only constructs able to return a value are variables, constants, functions, properties and methods (the latter 2 being special cases from to objects)

    Leave a comment:


  • Dheeraj Joshi
    replied
    Yeah they are backticks

    Code:
    $res=`php myfile.php`
    it executes file named myfile.php and gives the result back.

    Regards
    Dheeraj Joshi

    Leave a comment:

Working...