Jump to content

Xu Wei Jie

Members
  • Posts

    138
  • Joined

  • Last visited

    Never

Everything posted by Xu Wei Jie

  1. Anyone have any idea to this problem?
  2. Thanks . It is quite a neat solution. However I have a problem here. I am not interacting with integer parameters but a file name($new_id) of a file that contain objects Pseudocode to simulate the command " php 'filename' $new_id " $contents = runphp('filename', $new_id); How do I code that to your execphp function?
  3. ob_start(); and ob_get_contents(); are new to me The solution you gave seems viable if $new_id is just a variable. Are there any file functions that given a php filename, I can run it and get the contents? I am just using pseudo code here i.e. $contents = runphp('filename', second parameter....,third parameter...) fwrite($contents to another file)
  4. Let's take away the $new_id which is supposed to be a file containing objects Let src/$output_dir/$output be a directory, we will name it src/out.php I will run system("php $frame > src/$output_dir/$output", $retval); Let's create a dummy php file and its filename to be assigned to $frame $frame = dummy.php dummy.php <?php echo 'This is a dummy'' ?> If I ran a system command like this, it will run dummy.php and output 'This is a dummy' to src/out.php If I use file i/o libraries, i can never run or achieve something like php $frame $new_id which is a command but I do not wish to use system command, thus I was thinking how should I work around it. Placing file functions inside the script may help but it will also means a lot more lines of codes. If i can do something like what system() can do and using php in built functions only, it would be great. Any ideas or alternatives?
  5. What I heard was system function is very OS restrictive means it is not portable across platforms. Obviously I do know $frame is a php script. But i am exploring into php file i/o libraries to do the exact same thing as the command I typed does. The command does take in objects from $newid into $frame which is ran by system and direct its output to a specified file
  6. Yes I did take a look at the highlight function but it returns you additional html tags as well which is not what I wanted. What I wish to accomplish can be as simple as <?php echo '<?php echo 'This is a tag within a tag'?>'?> but I wish to find a more elegant solution. Because the above solution or the nowdoc syntax makes code hard to read. I would like to tell the parser to interpret certain php tags and escape certain php tags.
  7. Yup, that is why I am looking into php parsed tokens (http://sg2.php.net/tokens) to see how it can be done. Anyone have experience with using these tokens to interpret php tags? Would appreciate if you could share with me ^.^
  8. yah but a one liner becomes a 3 liner in nowdoc syntax
  9. I also think that nowdoc is very sleek. However, if I want it to be a single liner i.e. <?php echo "test"> to be processed as plain text The one that makes the most sense is <?php echo '<?php echo "test">'?> nowdoc just makes the code a multi line code. It will make it hard to read. Thus, I was wondering if I can tell the CLI not to interpret certain tags other than the solutions as typed above. I have extra information about the tags being interpreted as tokens (http://sg2.php.net/tokens) It states that <?php is interpreted as T_OPEN_TAG by the php cli. However , I don't know how to use it to my advantage.
  10. I forgot to mention. It goes through a PHP interpreter and not a server thus HTML tags would not be interpreted as well. I am trying to ask the PHP CLI not to interpret certain php tags.
  11. Do you think this UNIX specific command can be implemented using PHP in built libraries? system("php $frame $new_id > src/$output_dir/$output", $retval);
  12. That will be kinda messy. what if I just want to parse inline tags as plain text? How do I tell the interpreter which tags to parse and which tags not to?
  13. I read about this link ( http://sg2.php.net/tokens ) on how the parser treats php open and close tags as tokens. Previously, I asked about how to parse php tags as plain text and I was given solutions like using single quotes or the NOWDOC syntax. i.e <?php echo '<?php echo "this is just plain text"?>' ?> and <?php > echo <<<'EOD' > <?php echo "this is just plain text" ?> > EOD; > ?> I was wondering if there are any other solutions to escape php tags. Thanks everyone
  14. Yes, I am trying to use this function to direct PHP CLI processing outputs to files. But I am sure PHP file manipulating libraries should be able to do the same job but probably more cumbersome and involve more lines of codes. what do you think?
  15. Would you ever use the system function ( http://sg.php.net/system ) extensively to develop PHP applications? Does it have any issues?
  16. I have found out more. store_data() actually returns into $new_id another file name where objects are stored and serialized into. $frame is the name of another php file. Thus system("php $frame $new_id > src/$output_dir/$output", $retval); will run 2 CLI processes to direct the content of $frame into an output path and the other to deserialize the objects stored in $new_id. However there is something that I still don't quite understand. Does running php cli on 2 filenames interpret both of them and direct them into the output path?
  17. $new_id = store_data(......); The second variable basically gets its value from the statement above which I am not sure what it does.
  18. From a php file , i have some variables and an include statement that leads to another php file. How do I make these variables accessible to the file that I included?
  19. The first variables is the php file to be interpreted. I have no idea what is the second variable for.Thus, I am asking what could it be for? I normally use CLI like how I always used to i.e. php example.php
  20. I would not understand what does php $var1 $var2 do.....???????
  21. system("php $frame $new_id > src/$output_dir/$output", $retval); what does this function do? Any help would be appreciated . Thanks
  22. I have turned it on and ran the code again. Does it have a difference?
  23. <?php $module = array("Staff","Project"); $modeofaction = array("create","copy","edit"); $m=""; $ma=""; for($i=0;$i<count($module);$i++) { $m = $module[$i]; for($j=0;$j<count($modeofaction);$j++) { $ma = $modeofaction[$j]; editable_form(); } } function editable_form() { global $m; global $ma; if($ma=="create") { $editable_title = "New $m"; $editable_message = "Please enter the $m data"; $editable_action = $ma; $editable_nextAction = "confirmNewInstance"; } else if($ma=="copy") { $editable_title = "Copying $m"; $editable_message = "Please modify the $m data"; $editable_action = $ma; $editable_nextAction = "confirmCopy"; } else if($ma=="edit") { $editable_title = "Edit $m"; $editable_message = "Please edit the $m data"; $editable_action = $ma; $editable_nextAction = "confirmEdit"; } if (!file_exists("src2")) mkdir("src2"); $myFile = "src2/".$ma.$m."View.php"; $fh = fopen($myFile, 'w') or die("can't open file"); //editable details......... fclose($fh); } ?> This is my script. Why should I pass in as a parameter when it can be declared global? From the scripts I googled, global variables are used the way I coded it. Have I missed out on any implications that a global variable might cause problems?
  24. <?php function ab() { global $a; $a=2+2; } ab(); echo $a; ?> what could be the contexts that a global variable can be wrongfully used? My concern of a global variable is that it may get changed almost anywhere in different php files and will be hard to track.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.