tags:

views:

110

answers:

4

I'm making a new php page and I get the error

Fatal error: Call to undefined function phpinclude_once() in /home8/nuventio/public_html/marketing/pb2/dashboard.php on line 1

I'm not sure why I'm getting this error, I've done previous pages the same way as this with no problems. This is the line in question:

<?php
include_once("../utils.php");
?>

After that it just goes into regular HTML code. It works fine without that line.

+6  A: 

try making sure there is an enter between your <?php and your include_once

It seems like you might have short tags, and it is interpreting it as:

<? = Open Tag
phpinclude_once("../utils.php"); = Function call

So just put an extra line or something in there. You could even just add a few semicolons for the heck of it.

Chacha102
Beat me by 26 seconds!
Josh
Putting as many line breaks as I wanted didn't fix the error. However, adding a semicolon in DID fix it. Thanks!Do you know why it would do that when other documents on the server are formatted the same way and work fine?
Alex Zylman
@Josh LOL... that has happend to me by 13 seconds XD I know how it feels, so I'm going to give you an upvote too.
Cristian
@Alex I have no idea. My guess is there are some weird invisible characters making it act weird. The semicolon acts as a line delimiter, so it ensures that the next statement is treated as a new line.
Chacha102
`You could even just add a few semicolons for the heck of it.` - I really hope this isn't a serious suggestion. That's not how you solve a problem.
Peter Bailey
@Alex: What about putting a number of *spaces* instead of newlines?
Josh
It works with spaces... or semicolons... but not newlines.
Alex Zylman
+1  A: 

Delete the entire line and retype it. If PHP is saying the undefined function is phpinclude_once then something is very weird, it's almost like PHP isn't seeing the newline between <?php and include_once, interpreting it as <? phpinclude_once

Josh
+5  A: 

Perhaps your editing program is saving your PHP files using only carriage-return style newlines (\r or 0x0D)

Because, as far as I know*, the parser will only recognize linefeed-style newlines (\n or 0x0A)

*Someone please correct me if I'm wrong on this one.

EDIT

Could also be a transfer issue - I believe some FTP programs will do newline conversion and other OS-specific stuff.

Peter Bailey
@Alex Zylman: This is what I was thinking as well. What text editor are you using to edit the file?
animuson
+1 for Could also be a transfer issue. I *thought* PHP could handle \r as an end-of-line char but I'm not sure.
Josh
I'm using Notepad++ and Filezilla
Alex Zylman
@Alex that doesn't clarify anything - it's not the programs themselves but the settings for them. Can you determine which newline scheme Notepad++ is using for saving PHP files?
Peter Bailey
@Peter animuson asked me what text editor I was using. I was responding to him. Anyway, I already figured my problem out.
Alex Zylman
@Alex - Cool, but it's customary on Stack Overflow to mark an answer as "accepted" once you've solved the problem. Just click on the checkmark next whichever answer is most correct. Posting an answer to your own is generally not a good idea - just use the comments at the top for that type of conversation.
Peter Bailey
@Peter I was going to mark my answer as accepted, but it won't let me do it yet (apparently I need to wait a day). I didn't realize the posting an answer to my own isn't a good idea - the FAQ I read when I signed up says that it's encouraged, if you find the answer before you receive it. None of the other answers were really an "answer" - they were helpful in leading me in the right direction to solve it myself, but when it came down to it none solved my issue.
Alex Zylman
@Alex - I've tried to avoid tooting my own horn, but you force my hand. My answer is exactly what you fixed in your post. Older Macintosh operating systems use `\r` newlines, *nix uses `\n` newlines, and Windows uses `\r\n`. The EOL you mention in the settings is "end of line" which is another way of saying "newline character". So I was not only right about the fact that you had only `\r` style newlines, but that PHP on a *nix host wasn't interpreting them as well.
Peter Bailey
I realize that what you said was the correct information, but it wasn't an answer to my question. It described the problem in a way that led me to the solution but gave me no solution. That's why I said it helped me in the right direction, but wasn't really an answer. I mean, if you're upset about it I can mark your response as the answer, but like I said in my opinion it didn't really provide a solution - there just wasn't enough information.
Alex Zylman
When it comes down to it, I said your file had `\r` newlines which it did, so I don't really see the distinction you're making. But I'm not upset about it - you have total free will to mark whichever answer you want.
Peter Bailey
A: 

I fixed my problem (actually fixed, not a workaround).

Previous files were files that I had created myself. The files I was working on that were giving me this error had been given to me by a mac user.

In Notepad++, I found where it lists EOL info and found out that they were encoded using Mac EOL format which, while it looked fine in Notepad++, was not working once I uploaded it to my server (a *nix environment). In Notepad++, I converted the EOL to Windows format (either that or UNIX format worked, but Mac format doesn't). This is under Edit -> EOL Conversion.

Alex Zylman