Jump to content

sandeep529

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Posts posted by sandeep529

  1. By the way, is there a way I could pack this all into a method?

     

    You could create an anonymous function using create_functon  so after using that and packing it into a function that your code will become

    $stage1 = "This is the free version, here you are #code#<?php
    echo \"This is the code\";
    echo \"<br/>\";
    echo \"and some more code\";
    ?>#/code#";
    
    function escape_code($stage1) {
    
    $callback = create_function('$src','return  "<div class=\'stylearoundcode\'><br/>".htmlentities($src[1]) ."</div><br/>";');
    
    return  preg_replace_callback("/#code#(.*)#\/code#/sm",$callback,$stage1);
    }
    
    echo escape_code($stage1);

     

  2. However, Sandeep's outputs nothing as for now.

     

    That seems strange, I have tested this and it was working. Can you tell how you tested?

     

    I want to replace the area where the code tags were with <div class=stylearoundcode> and </div>

     

    This could be done by change the line in callback function from

     

    return htmlentities($src[1]); 

     

    to

     

    return "<div class='stylearoundcode'>".htmlentities($src[1]) ."</div>" ; 

     

     

     

     

     

     

  3. Hi,

     

    I believe you want to replace the content inside the #code# tags to be replaced by its htmlentitied  version. If this is so please try this

     

    $stage1 = "This is the free version, here you are #code#<?php
    echo \"This is the code\";
    echo \"<br/>\";
    echo \"and some more code\";
    ?>#/code#";
    
    function callback($src)
    {
    return htmlentities($src[1]);
    }
    
    $stage1= preg_replace_callback("/#code#(.*)#\/code#/sm",'callback',$stage1);
    
    echo $stage1;

     

     

  4. and what exactly did u mean by remove lines from the second block so that it becomes like the first block?

     

    Point is to change the second block gradually so that at some point,( if it is due some code present in the second block that makes it work), it will stop working. at that point you can be some what sure that the last line you removed was the one that makes the code in the first block work.

     

    what i don't understand now is what determines the order of execution?

     

    The ready methods are executed in the order they are bound. please see the threads

     

    http://stackoverflow.com/questions/3934570/order-of-execution-of-jquery-document-ready

     

    http://stackoverflow.com/questions/1307929/javascript-dom-load-events-execution-sequence-and-document-ready

     

     

  5. Hi,

     

    I went through your code and found nothing wrong with it. I think this may have something to do with the order in with the document.ready methods are being executed. If I am right the ready methods execute in the order in which they are bound. 

     

    You can try somthing like as follows

     

    Remove lines from the second block so that it becomes identical to the first block.

    If it still does not work change the order of the blocks so that the second block is executed before the first block.

    If it is still not working, we may have to use debugging tools like firebug for firefox to check what exactly is happening.

     

    Good luck

  6. I use the gvim with the following plugins

     

    Tablistlite plugin:

     

    http://www.vim.org/scripts/script.php?script_id=3680

     

    This enables me to switch tabs lightning fast.

    I have mapped the command to open the tablist window to F2 key. This enables me to switch between different tabs without even thinking as the tablist is sorted on the basis of last accessed tab so the key sequence <F2> <Enter> will switch between the current tab and the tab you were previously in. and also

     

    <F2><Down arrow><Enter>  => to 2nd last accessed tab

    <F2><Down arrow><Down arrow><Enter>  =>to 3rd last accessed tab  And so on

     

    functionlist.vim

    http://www.vim.org/scripts/script.php?script_id=3681

     

    This plugin opens window on the rhs that contains a list of function names detected in the current script. Function names are sorted alphabetically.

    Press any key and the cursor moves to the function names atarting with that letter. Pressing enter on a function name moves the cursor to that function in the code window.

     

    Just map the command to open the function list to some function key.

     

    Nerdtree plugin

     

    http://www.vim.org/scripts/script.php?script_id=1658

     

    This opens a file browser window in the lhs of the current window. You can do basic file opertaions like opening,opening in a new tab, delete/move/add files from the pluggins window itself.

     

    If you take some time to learn vim, then there is really no going back...So i think...)

     

    regards,

    Sandeep

     

     

  7. perhaps go a little more in depth with the actual tutorial, maybe explain what exactly the user is doing when they type what the tut tells them to.

     

    The problem is I have blocked constructs like echo and print_r due to security reasons.

     

    Now I have moved the statement input box to the top of the instructions so that I can have more contents in the instruction box.

     

    Is it better now?

  8. Hi..It looks pretty nice...but....

     

    I just feel the colors are a bit dull and the footer graphics is kind of depressing..( lot of brown emptyness ..) .may be adding a couple of birds and may be a rising sun....I understand it is a matter of taste, so please feel free to ignore my comments.

     

    and I also agree with a previous post that says contact form should be moved from footer...

  9.  

    But I began to notice that some of my jQ codes wouldn't work at all when isolated in their own unique document ready method.

     

    Are you sure your code in executing in correct scope..Any variable that is initialized inside a function using the var keyword will have a local scope. If a variable is initialized inside a function without var, or it is declared outside if a function, it will have a global scope...so the issue might be your code may be using some variables declared inside a certain function so when they are moved to another scope, the code can no longer access those variables and stop wonrking

     

    Please post some code samples so that you may get an accurate response.....

  10. What is the point of this website exactly?

     

    The page is supposed to demonstrate the capabilities of a php class for manipulating xml strings. There is a field for entering php statements that uses the class. It is a type of self guided tutorial on using some functionality of the class. Instructions are shown in the gray box. Every instruction asks user to enter some statement into the input field. Upon pressing enter, That statement is evaluated via ajax and result is shown in the right box.

     

    I need to know if you were able to figure out how to use the demo? Or should I make some changes in layout to make it more usable?

     

    Thanks for trying....

  11. The only problem is, it becomes difficult to tell if the array you have set for the 'bar' option defines default values 9as you posted) or is actually the default value for 'bar' itself.

     

    Why not solve this by specifying the default value in the 'default' key . Ie

     

    This defaults aray would become

     

    $this->setDefaults([

                'foo' => ['default'=>'foo' ],

                'bar' => ['required'=>true],

                'boo' => ['required'=>true,'type'=>'Something']

            ])

     

  12. Hi,

     

    I havent used traits yet to implement anything..so pls excuse any inexperience with it...but I was thinking if the options object is necessary.

     

    I mean can its use be simplified as

     

    class Foo
    {
        use Options;
    
        public function __construct(array $options = array())
        {
            $this->setDefaults([
                'foo' => 'foo' ,
                'bar' => ['required'=>true],
                'boo' => ['required'=>true,'type'=>'Something']
            ]);
    
            $this->setOptions($options);
        }
    }
    

     

    And in trait definition

     

     

     private function setOptions(array $options)
        {
            foreach ($options as $key => $value) {
                if (isset($this->options[$key])) {
                  
               //validate if the value passed in $options for $key is the type specified in $this->options[$key]
                    
                } else {
                    $this->options[$key] = $value;
                }
            }
    
        }
    

     

    Regards,

    Sandeep

     

     

×
×
  • 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.