Basically my question is How do you get the value of a variable inside a js file.
E.g
var now = (new Date() - 0);
other_var = 'Whats up';//how to pull the value of the other_var which is 'Whats Up'
key.embed();
How do get the value of the other_var using php? I only need the value of the variable which is ‘whats up’.
Made some digging on my own, now I am able to get the content of the js file using file_get_content function in php, just don’t know how to pull get the variable and pull its value.
Example
Something like that? Note that it would only find string values as it looks for quotes, and there are various holes in it that allow it to match a few things that are syntactically invalid Javascript and it will fall down when there are escaped quotes in the string – but as long as the JS is valid, that should find the first place in the file where a string value is assigned to the named variable, with or without a
varkeyword.EDIT
A much better version that only matches syntactically valid Javascript strings and should match any valid single strings including those with escaped quotes, although it still won’t handle concatenation expressions. It also gets the actual value of the string as it would be when loaded into Javascript – i.e. it interpolates escape sequences as defined here.