I've never manipulated strings much just replacements or stripslashes because I've always been involved in math programs.
I'm stuck now because I do know string functions but I have a form input that accepts HTML and after checking isset and assigning to a variable I can echo it perfectly but I try strlen or to search strstr or just strpos and it returns false. What is it if not a string?
if not a string, what?
Moderator: General Moderators
-
mikeashfield
- Forum Contributor
- Posts: 159
- Joined: Sat Oct 22, 2011 10:50 am
Re: if not a string, what?
do:

Code: Select all
echo gettype($value);Re: if not a string, what?
always a function I don't know out there - Thanks
the damn thing echoed string, the variable echoes all the HTML code, but if(strlen($var) > 0) { echo 'yes'; } nothing
Thanks again, though frustrated at least I know that knowing that it WAS a string wasn't crazy as I was beginning to think
the damn thing echoed string, the variable echoes all the HTML code, but if(strlen($var) > 0) { echo 'yes'; } nothing
Thanks again, though frustrated at least I know that knowing that it WAS a string wasn't crazy as I was beginning to think
Re: if not a string, what?
Well, throwing things at it and preg_match worked.
-
mikeashfield
- Forum Contributor
- Posts: 159
- Joined: Sat Oct 22, 2011 10:50 am
Re: if not a string, what?
I suggest you take a good look at what's inside the $HTML variable as I think that's what causing you problems. I just did the following with no errors:
Code: Select all
<?php
$HTML = "<html><head><title>Test 'title'</title></head><body><h1>Testing</h1><p>Testing</p></body></html>";
echo gettype($HTML)."<br />";
if (strlen($HTML) > 0) {
echo "Valid variable length"."<br />";
echo $HTML;
} else {
echo "Invalid variable length";
}
?>
Re: if not a string, what?
I knew the string was large but php.net manual says: Note: It is no problem for a string to become very large. PHP imposes no boundary on the size of a string; the only limit is the available memory of the computer on which PHP is running.
Re: if not a string, what?
Pondering after I posted, I'm going client side to create more hidden inputs that just catch what I need.