I have just installed fresh PhpStorm on Mac. I set my interpreter and so on. I can create .php files. But when I run it runs only JavaScript and there is no option to run php? How can I fix this?
Run 'filename.php (JavaScript...)'
Same with debug. How this can be fixed?
It seems you've configured PhpStorm to handle files with .php extension as JavaScript code rather than PHP.
Open the settings dialog (File/ Settings), head to Editor/ File Types and review the Recognized File Types section:
Remove *.php from JavaScript.
Make sure that PHP contains *.php.
Remove any other unwanted registered pattern, such as filename.php.
Related
I think I broke mi VS Code trying to join php and html syntax when I have a php file with html and php code.
The problem is that VS Code doesn't recognize .php files. The Select Language Mode shows as a 'Plain Text' and when I try to configure file association for '.php' doesn't appear.
I try a solution found "php.validate.excecutablePath" and I did not have results.
Finally I tried installing again VS Code after uninstall and delete all but doesn't work.
I don't know what to do.
I know it's very late lmao, but here's what I found; In order to make the setting re-appear, uninstall any extra php related extensions and restart vscode (you might also want to disable and re-enable php through searching "#builtin php" in extensions). That should bring the option back; then go and set up the path in the settings.json, and if you are a windows user add it to your environmental variables (specifically path).
i added php code in my cshtml view under asp.net mvc.
<body>
<?php echo"hello";?>
...
however it seems that vs does not understand that it's php and when I inspect element, the php code was automatically commented out.
<!--?php echo"hello";?-->
how can I solve this? I have already installed php tool extension in vs.
To run php script, you need to have .php files, or it won't be recognized.
To enable the script to be recognized as php without changing file suffix, add config files depending on the server you are using. (most likely Apache/IIS)
I have a html file and I want to run PHP code to call out an array value within HTML form box but the interpreter doesn't recognize
<input value="<?php echo $_SESSION['user']; ?>"/>
p.s. Not sure if it makes any difference but I am running this on cloud9 with apache (httpd).
Save your HTML file as a PHP file since HTML files cannot execute php code. For example if your file is named index.html you want to re-save it as index.php once you do that your php code should run.
HTML files does not parse PHP. You need to have a file with .php as extension to run PHP.
PS: Its possible to make HTML file run PHP as well but that requires some extra settings in apache config which is never enabled by default. Reason being a security threat. But If you have a dedicated server which allows playing with apache config then you can achieve this..
have a look at this LINK
Ok I figured out that it was actually working all along =/ (i was only looking at the local IDE display within cloud9 but the code was working all along since it actually required back-end processing and the local IDE won't display that).
I have Joomla installed in my computer, but recently have been writing php files that aren't related to the Joomla-managed site. For some reason, when I try to open those php files in the web browser using xampp (note: Joomla also is using xampp), the browser doesn't process the code w/in the tags as php code.
For example, after opening a basic page (a page with title "test", no content except in the body tags) in the web browser and going to the source code, the following is shows up in the source code:
<body>
<?php echo "hello"; ?>
</body>
instead of the HTML conversion. (i.e. just "hello")
Does anyone have an idea about what's going on here?
Thanks.
It's probably because PHP module isn't loaded in your apache. Be sure it is enabled
PHP is interpreted in the server, not the browser. Whatever's going wrong, you need to look at the SERVER side to resolve it.
My first guess: maybe you didn't suffix the file ".php" (so the server doesn't recognize it as a PHP file?)
Second guess: is the directory containing your PHP files configured to parse PHP?
If you have Joomla, you probably have PHP. You probably also have Apache.
So check your Apache configuration, and check your file naming conventions.
Is the file extension .php? The server doesn't magically know when you're serving php files, this is a good way to ensure it knows what you're doing.
Apache is looking into your localhost's defined root directory for files it can parse. In this case htdocs. This is the default for XAMPP. As far as Apache is concerned, it will not interpret any files outside of that folder.
if the problem in php module it better to re install php5 in to the system and it will work fine. probably the problem is in php module you should try re installing php in your system.
Just restart httpd service. It will work fine.
sudo systemctl restart httpd.service
if it has not worked please reinstall PHP once again.
I took over a PHP project and I'm trying to get it running on my dev box. I'm a developer and not a sysadmin, so I'm having trouble getting it working.
The previous developer used .h files to include PHP. My current configuration is taking that .h file and including it without executing it. What do I need to look for in my apache config (or is it my php.ini)?
EDIT:
Something clicked when I read one of the comments below. The code is using ASP style tags "<?". I've turned the option on in php.ini and according to phpinfo(), it's enabled, but apache is still just including the code as text.
I just checked it and running the code with the full opening PHP tag "<?php" fixes the problem. Having said that, I'd still like it to work the other way.
I'm running the code on a Macbook with the latest versions available. PHP 5.2.6, postgresql 8.3 and apache 2.
The code works on the staging server, but I can't figure out what the difference it.
EDIT
Durrr...I didn't have short_open_tags enabled in php.ini.
Could the problem be that the .h file you are including just starts into php code without the opening "<?php" tag?
From include documentation:
When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.
PHP is an interpreted language, so you can't 'include' a file without executing it. Remember that '.h' is just a file extension, so although the previous coder may have put PHP in a '.h' file, it's still just PHP.
More details on the problems you're running into would be helpful.
you can use a .htaccess file and add:
php_value auto_prepend_file /path/to/include-file.h
Edit
I've just read that .htaccess only works with the module version of php.
You should change them all to .php extensions. But, if you are going to leave them as .h, you change the mapping in Apache. It's Apache that runs the file through the proper interpreter, not PHP. The PHP engine will process anything passed to it.
include and require will execute the included file. If you are using readfile, it simply echoes the file without treating it as PHP code.
If the .h files are "missing" the <?php directive, then you may have to switch from include to something like:
eval( file_get_contents("file.h") );
Personally I try to avoid eval whenever I can, but sometimes there is just no choice.