Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

css like PHP page.

Featured Replies

I made a formatted php page. like css with php. For some reason the page is blank and when i check the source code there is none. it may be problems with my server, but i hope not.

 

Please help.

Edited by wolf125

Not too sure what you mean but chances are there is an error in your code and you have error reporting off so you just get a blank screen. Switch error reporting on.

  • Author

I don't know how. What would i even mess with. My server, my code, what?

Edited by wolf125

post code or switch error reporting on and post error otherwise nobody can help you.

  • Author

post code or switch error reporting on and post error otherwise nobody can help you.

Post to this site?

  • Author

Here it is:

 

 

<?

$agent = getenv("HTTP_USER_AGENT");

 

if (preg_match("/Win/i", "$agent")) {

$style = "win";

} else if (preg_match("/Linux/i", "$agent")) {

$style = "linux";

}

 

$win_style = "<style type=\ "text/css\">p, ul , ol, li

{font-family:Arial;font-size:10pt;font-wheight:normal;}

h1 {font-family:Arial;font-size:16pt;font-wheight:bold;}

h2 {font-family:Arial;font-size:14pt;font-wheight:bold;}

strong {font-family:Arial;font-size:10pt;font-wheight:bold;}

em {font-family:Arial;font-size:10pt;font-style:italic;}

</style>";

 

$linux_style = "<style type=\"text/css\">

p, ul, ol, li {font-family:Times;font-size:12pt;font-wheight:normal;}

h1 {font-family:Times;font-size:18pt;font-wheight:bold;}

h2 {font-family:Times;font-size:16pt;font-wheight:bold;}

strong {font-family:Times;font-size:12pt;font-wheight:bold;}

em {font-family:Times;font-size:12pt;font-style:italic;}

</style>";

?>

 

<html>

<head>

<title>Platform Matching</title>

 

<?

if (style == "win") {

echo "$win_style";

} else if ($style == "linux") {

echo "$linux_style";

}

?>

 

</head>

<body>

 

<h1 align=center>This is a level 1 heading</h1>

<h2 align=center>This is a level 2 heading</h2>

<p align=center>This is a simple paragraph with some

<strong>bold</strong> and <em>emphasized</em> text.</p>

 

</body>

</html>

You have missed your $ off $style in your if() statement near the bottom.

Also, remove the space between else & if

 

And perhaps change <? to <?php

  • Author

that was an error in the code and thanks, but i still don't see anything.

Add this to the top (inside php tags of course)

 

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

 

I notice there are 2 instances where you have added a space between else & if

Edited by Blofeld

  • Author

Also, remove the space between else & if

 

And perhaps change <? to <?php

those have worked for my php before, and also i still don't see anything when i try. i am almost certain it is a server error.

those have worked for my php before, and also i still don't see anything when i try. i am almost certain it is a server error.

 

Which? The short tags or leaving a space?

  • Author

Add this to the top (inside php tags of course)

 

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

 

I notice there are 2 instances where you have added a space between else & if

thanks again, but still nothing. all there is is a blank screen and no code. i have checked if i didn't type in the right address, but it seems to be right after 4 or 5 times and i am convinced it's the server or something else. correct me if I'm wrong though.

  • Author

Which? The short tags or leaving a space?

both work for both ways, but not on when i look it up after posting it through my server.

The only other error I can see is the space between \ and "

 

$win_style = "<style type=\ "text/css\"

And if the error reporting code I posted doesn't work you need to do it from within your php.ini file (if there ain't one, create one. You should always develop with error reporting on otherwise you'd be at it forever!

 

Inside php.ini

error_reporting = E_ALL
display_errors=On

Edited by Blofeld

  • Author

Thanks man. That last one fixed it. The oddest thing though is how that would keep me from viewing the source code. any idea on that??

Because you have error reporting set to 'off'! If php has a fatal error the page won't load anything. If you have it switched 'On' it would show the error and line number.

  • Author

that's odd. it's doing it again. it was right after your last bit of code.

Edited by wolf125

that's odd. it's doing it again. it was right after your last bit of code.

 

Again!!! This:

 

And if the error reporting code I posted doesn't work you need to do it from within your php.ini file (if there ain't one, create one. You should always develop with error reporting on otherwise you'd be at it forever!

 

Inside php.ini

error_reporting = E_ALL
display_errors=On

  • Author

your very last bit of code did the same thing, because when i took it out it worked perfectly.

Again!!! This:

 

 

 

Sorry for butting in Blofeld, but this should solve his problems

 

<?php
$agent = getenv("HTTP_USER_AGENT");

if (preg_match("/Win/i", "$agent")) {
$style = "win";
} else if (preg_match("/Linux/i", "$agent")) {
$style = "linux";
}

$win_style = "<style type=\"text/css\">p, ul , ol, li
{font-family:Arial;font-size:10pt;font-weight:normal;}
h1 {font-family:Arial;font-size:16pt;font-weight:bold;}
h2 {font-family:Arial;font-size:14pt;font-weight:bold;}
strong {font-family:Arial;font-size:10pt;font-weight:bold;}
em {font-family:Arial;font-size:10pt;font-style:italic;}
</style>";

$linux_style = "<style type=\"text/css\">
p, ul, ol, li {font-family:Times;font-size:12pt;font-weight:normal;}
h1 {font-family:Times;font-size:18pt;font-weight:bold;}
h2 {font-family:Times;font-size:16pt;font-weight:bold;}
strong {font-family:Times;font-size:12pt;font-weight:bold;}
em {font-family:Times;font-size:12pt;font-style:italic;}
</style>";
?>

<html>
<head>
<title>Platform Matching</title>

<?php
if ($style == "win") {
echo ($win_style);
} else if ($style == "linux") {
echo ($linux_style);
}
?>

</head>
<body>

<h1 align=center>This is a level 1 heading</h1>
<h2 align=center>This is a level 2 heading</h2>
<p align=center>This is a simple paragraph with some
<strong>bold</strong> and <em>emphasized</em> text.</p>

</body>
</html>

 

Pat

  • Author

what does php.ini mean? I'm sorry. I am a severe case of programming noobness.

just create a file called php.ini in the same directory as the file you are working on and add those 2 lines. It is how you change php config settings.

Cheers Pat! I suppose I should have just done that in the first place...I just thought it best he knew which bits were causing the trouble.

  • Author

well it does work. thanks guys. although i don't know what php.ini means. if it wouldn't be too much trouble, what is it?... never mind,. you guys type fast

Edited by wolf125

  • Author

Blofeld. you should know that i just checked his code against mine and fixed it. I don't just copy and paste.

  • Author

you guys know how to make a code have an ini file extension?

  • Author

you guys know how to make a code have an ini file extension?

actually, dont reply. I'll just make a new topic. I should have done that earlier. if you want to look it will be

 

ini extention

Edited by wolf125

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.