Priyanka23 Posted January 4, 2023 Share Posted January 4, 2023 Hi friends, Please tell me why this simple line of code is not executing? I saved it in a file called 1.php <?php echo 'One line after another line'; ?> Thanks & Regards, Priyanka Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/ Share on other sites More sharing options...
mac_gyver Posted January 4, 2023 Share Posted January 4, 2023 Php 101 - php is a server-side scripting language. do you have a web server with php installed? the php file must be placed in the web server's document root folder, which may have different paths/names depending on what operating system is in use and how you obtained and installed the web server/php. to run a php script, you must make a http(s) request to the web server. what URL did you use in your browser to request the file? it should be something like - http://localhost/1.php (for a localhost development system.) if is starts with file:///..., that's not a URL, that's a filesystem path, which means that you opened the .php file directly in the browser, which won't invoke the php language engine that's installed on the web server. if you made a http(s) request to a URL and got a blank page, what does the 'view source' of the page in your browser show? you can also check in your browser's developer tools, network tab to see what the response is. Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604191 Share on other sites More sharing options...
Priyanka23 Posted January 4, 2023 Author Share Posted January 4, 2023 Yes , I have XAMPP installed & other php files are running fine!! So no problem regarding "being in root folder or not". So please tell me if there is any syntax problem? Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604192 Share on other sites More sharing options...
mac_gyver Posted January 4, 2023 Share Posted January 4, 2023 what output do you get, e.g. item #4 on my list? do you have php's error_reporting set to E_ALL and display_errors set to ON, in the php.ini on your system, so that php will help you by reporting and displaying ALL the errors it detects? stop and start your web server to get any changes made to the php.ini to take effect and check using a phpinfo(); statement in a .php script that the settings actually got changed to those values. Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604193 Share on other sites More sharing options...
Priyanka23 Posted January 4, 2023 Author Share Posted January 4, 2023 This is the error line I am getting - Parse error: syntax error, unexpected ''One line after another li' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\demo\err1.php on line 2 Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604194 Share on other sites More sharing options...
Solution mac_gyver Posted January 4, 2023 Solution Share Posted January 4, 2023 there's nothing wrong with the POSTED code (just tested.) errors like this are usually caused by copy/pasting code that's been published on the web, with smart/curly quotes, which then produce php errors since those type of characters have no meaning in php, but which get converted back to straight quotes when code gets posted on a programming help forum, and therefor work when tried. delete and re-type the line of code. 1 Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604195 Share on other sites More sharing options...
Priyanka23 Posted January 4, 2023 Author Share Posted January 4, 2023 Oh yaa.. Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/315759-echo-not-outputting-anything/#findComment-1604200 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.