Jump to content

Recommended Posts

Hi, I'm new here

 

my father (and co-worker) told me to interact with a few communities that it would be good for my professional carreer.

However I can't just come here and take whatever I want, so I offer you guys this piece of code.

 

*attached*

 

Sorry for the autodoc comments in portuguese, I'm from Brasil.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/239355-string-class-for-php/
Share on other sites

so uhh... what do you think of the class?

useful, unuseful? something I forgot to do?

feedback is what keeps me working

 

and don't worry, I don't like to use code people give me. I need to read, understand and then adapt a solution to my problem :)

You do no error-checking like:

 

public function charAt($index){
  return new String(substr($this->value,$index,1));
}

 

If I pass in $index >= $str->length() it returns false, resulting in:

 

return new String(false);

 

Not all methods are fully implemented:

 

public function split($delimiter,$limit=false){
		$limit = $limit ? $limit : strlen($this->value);
		$primitive = explode($delimiter,$this->value,$limit);
		$list = array();
		foreach($primitive as $str){

		}
	}

Thank you!

 

@the first note:

new String(false) is ""

it will concat false to the empty value and return empty, which you can eval as false

 

@the second note:

now it got fixed

I remember trying to use my List class there (the same as using array but as class methods and not language functions) but then I wanted the classes not to depend on eachother and forgot to write the 2 missing lines.

 

*attached new file*

 

ps: for some reason I can't modify the first post to upload the new file there too

 

[attachment deleted by admin]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.